A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

learn more… | top users | synonyms (2)

0
votes
1answer
23 views

Script add's md5sum to duplicate filenames but still get error notifications when executed

So by using some info from other threads on this site I have managed to get a script to copy files to another directory, then add the md5sum into the duplicate file names. However, I'm not fully ...
-6
votes
1answer
81 views
0
votes
1answer
37 views

Ignore parts of script under some circumstances?

My script looks like this strenggen ( ) { something; } strengen 1 strengen 2 strengen 3 strengen 4 strengen 5 etc.. Which adds a few files to the directory called strengen?string=1, ...
1
vote
3answers
199 views

How to split a “one-line text”, based on pattern? [closed]

I have a 1 line file ,contains non graphic characters and I want to split it based on a pattern. My pattern is \[0-9][0-9][0-9]; how can I do it? For example, I want to split this line: \001abd ...
2
votes
2answers
74 views

echo the directory with the information

The following script is working, I would like one more piece of information to the result. Besides the service rtvscand status, I also want to add where the file resides. Like: the symantec file ...
3
votes
2answers
48 views

Remove all but the latest backup file monthwise

I've got a directory, containing lots of weekly generated files with names like db_20130101_foo.tgz db_20130108_foo.tgz db_20130115_foo.tgz ... and so on. Over the years, the disks will get ...
2
votes
2answers
276 views

RHEL 7 how run longtime script before shutdown/reboot systemd

I'm trying to found solution how run script before shutdown/reboot is initiated in RedHat7. I need to correctly shutdown SAP database when I'm shuting down or rebooting server. Script for SAP ...
1
vote
2answers
44 views

Bash Script: No such file or directory when defining variable via source vars.txt

I have a script that creates a hash of a file, writes it to vars.txt and then checks that variable next time the script is run to determine if the file has changed. Here is the script and vars.txt ...
1
vote
1answer
70 views

Get IP Address of Main Interface in Ubuntu and Mac

I need to write a script that gets the IP address of the interface that is used for unknown routes (e.g. where 0.0.0.0/0 is routed through) That script should work on Ubuntu, Debian, Arch and Mac OS ...
0
votes
2answers
76 views

How to check all desired files have been downloaded in shell script

I have downloaded the files from remote server by sftp.now i want to check that all of my files (nodeid given) have been donwloaded or not.if not downloaded then give the warning messages by sendmail. ...
0
votes
1answer
57 views

Script inside bash shell thats inside another bash shell [closed]

I'm trying to run a simple program #!/bin/bash bash echo "Hello World" But the program only gets as far as the 'bash' command on line 2. Why can't the program run line 3? The program terminates at ...
0
votes
1answer
80 views

#! /bin/bash or #! /usr/bin/env bash? [duplicate]

I'm trying to write some provisioning shell scripts for Vagrant dev environment. I'm used to start bash scripts as follows #! /bin/bash But after surfing through some git repos I found out that in ...
0
votes
2answers
45 views

How to loop over each file in a directory, if and only if the directory contains the .csv files?

/dir1/--$ ls 1.txt 2.ssl.txt If the dir1 directory has the given .csv files, then only process the files listed in the .csv in a loop one after another. Here as the dir1 does not have any files ...
0
votes
0answers
42 views

Logging to a file in tabular format

I am trying to print something into a file through the script which will be sent as an attachment to the mail. Now what i am willing is to preserve a proper formatting within the file. Can i print ...
0
votes
4answers
50 views

How to log from inside the script along with stdout

I am aware that I can log using tee But I want to log from inside my script, at the same time display the content on the stdout. Example, my code looks something like this: names=$(print("name1 ...
0
votes
2answers
110 views

Check whether an IP belongs to a specific range

I have a log file that lists whitelisted IP ranges in this manner: "217.29.0.0-217.29.255.255", "204.12.0.0-204.12.255.255", "198.54.223.0-198.54.223.255", I am also working on a bash script which, ...
0
votes
1answer
59 views

CentOS and Stop Shell Script running on screen

I'm trying to automatize my system, sorry but I'm not very experienced on Linux distros, actually using CentOS 7. Every time I restart the machine I need to do: screen -S bun then on that screen I ...
1
vote
0answers
85 views

script can't write to systemd journal

to make it short: I want to write to the systemd journal from a script. printf "%s\n%s\n%s\n" CODE_FILE=/etc/zsh/zprofile CODE_LINE=31 MESSAGE="could not read /etc/dircolors" | logger --journald ...
0
votes
1answer
91 views

Running two commands at the same time?

Here is the nature of my problem: I'm using my raspberry pi to run a wikipedia server, so I'd like to make a launcher (desktop icon) that starts up the wikipedia server and opens the web browser to ...
1
vote
2answers
459 views

Cron Bash Script - echo to current terminal instead of /var/spool/mail/root

Is it possible for a Cron Bash Script to echo to the current session terminal instead of /var/spool/mail/root I have a script which writes errors to a log file but any supplemental/unimportant info I ...
1
vote
1answer
21 views

Interactive bash script

I'm writing a script that shuts down the Apache service, performs a function, and turns it back on. I'd like to get some type of interactive confirmation for each process. I'm not familiar with ...
0
votes
0answers
87 views

How to write a script with Android Debug Bridge command in it

I am trying to write a script to automate some testing, and the fist step is connect to my device and update the /lib/modules/ directory with the recent version of a device driver on my host. That is ...
2
votes
1answer
38 views

Launch a command when connected to a host

In a dormitory I live in the access to Internet is somehow clumsy. The procedure follows Connect to the network (via WiFi/Ethernet) Login by ssh sshpass -p password ssh login@domain.edu.pl ...
1
vote
2answers
152 views

What type of file is /dev/core or /proc/kcore?

While scanning a filesystem for changes with a shellscript, I forgot to exclude /dev, so core got tested too. Strangely enough, which ever way I test it, it is not consistent for a type: $ if [ -f ...
0
votes
0answers
79 views

permission needed for Python to access USB drive?

I got this Python script that reads media files from USB stick. It used to run fine, today it keeps giving me OS Error: [Errno 13] Permission denied: media/myName/usbName when the script runs the ...
4
votes
1answer
62 views

How to find how many windows are opened in GNU screen?

I am trying to automate my work flow. I have a script that opens individual window in screen for each IP in a list. Imagine setupscreen.sh <IP1> <IP2> .... After all windows are open, each ...
0
votes
1answer
59 views

Compare first column of 2 files based on the second column using the delimiter ;

I need to compare below 2 files. The head_file: 2345;int builder( 1000;char type::edit::display <test>( 250;void unamed_string_tree* The ref_file: 2000;int builder( ...
0
votes
1answer
39 views

How can I replace a filename with .ear in a file-list using sed?

I have a file whose contents look like: /appl/as/var/spool/ears/mps/ear1.ear ... I want to replace the name of only ear1.ear with ear2.ear and I am using the below sed command, but with no luck: ...
0
votes
2answers
50 views

Grep for string but ignore commented out items with string

I'm looking for the words gmail or outlook in a directory. Although there are some lines commented out with the word gmail and outlook in it. How can I grep for this? I tried a bunch of things but I ...
0
votes
0answers
26 views

Preserve formatting of the attachment sent by the script

I have written a script which at the end of execution send a mail with an attachment. Through my script i am making two files , one serves as email body and the second as an attachment. I noticed ...
0
votes
0answers
48 views

How to parse the output of running bash script?

I'm writing a simple bash script for downloading files via aria2c. I would like to parse the progress display so I can display it in the form I want. Currently the output looks like this: *** ...
3
votes
4answers
216 views

Bash script condition always passing even when grep should return nothing

I am having issues when trying to return the one image file that fits the parameters. $1 is the search parameter, in this incident it is "real" which is a tag on one of the images (not two) in the ...
1
vote
2answers
62 views

`last` alternative showing logins only for current user

I'm aware that I can use last $USER, however this won't work correctly or securely on machines with many users - no user should know another users IP or when they logged in. Is there a known solution ...
2
votes
3answers
533 views

how to implement logrotate in shell script

test.sh #!/bin/bash echo "Hello World" test2.sh #!/bin/bash while true do sh test.sh >> /script_logs/test.log & done I want to implement logrotate to control the log file size, so ...
2
votes
1answer
149 views

Rsync backup script for multiple servers

I have simple script that backing up data from remote server via ssh using rsync. I have external config file for that. In this config file I have variables: OPTIONS, REMOTE_IP, SOURCE and ...
0
votes
1answer
44 views

Bash script - sshing into one computer and then immediately into that comupter's network's modem

I am currently attempting to automagically reboot my modem that for some reason or another will only allow certain types of small Linux OS's to ssh into it - and not the one I am using. So, rebooting ...
2
votes
1answer
86 views

Background vs foreground task and running tasks in parallel

Since I'm new to Linux, apologies if I'm not using the correct terminology. I'm trying to run a number of tasks in parallel (using the background shell operator). However, I need to first run two ...
4
votes
3answers
63 views

Script that outputs the total number of lines in all the text files that are passed as arguments

So I'm working on a script that will accept arguments that are text files, and should output the total number of lines in those files.  For example, if I say ./myScript file1 file2 file3 it will ...
0
votes
1answer
61 views

How to get a position of a specific image within another image?

I have many PNG screenshots with an identical piece of graphic in each of them. The piece has the same dimensions in all of the images. What command line program can I use to find the position of it ...
1
vote
1answer
57 views

AIX Non GNU tool for text replacement

Contents of the file : PS1="$(hostname):${LOGNAME}:\${PWD} ${PROMPT} " PS1="${FGOLD}$(hostname):${LOGNAME}:\${PWD} ${PROMPT} ${NORMAL}" PS1=abd PS1="$(hostname):$LOGNAME:\$PWD $PROMPT " export PS1 ...
0
votes
1answer
89 views

ARRAY- Accept user input and output the corresponding choice from array

I'm working on a script that has an array of around 10 elements. All I have to do is that the script will accept user input of minimum 0 elements and maximum 10 elements (of the array) and it will ...
0
votes
1answer
48 views

Using RS-232 output as keystrokes

I'm a bit desperate now. I've been trying to do a simple thing (under windows it IS very simple) as reading RS-232 data and sending it as keystrokes. I tried softwedge - which is supposed to do ...
3
votes
3answers
426 views

How to rename multiple files to their contents' MD5 sum?

I would like to rename some files to their contents' MD5 sum; for example, if file foo is empty, it should be renamed to d41d8cd98f00b204e9800998ecf8427e. Does it have to be script or can I use ...
4
votes
4answers
601 views

Delete several lines from a file using grep

I have a file with multiple lines which looks like that : brand,model,inches,price dell xps 13 9000 macbook pro 13 13000 asus zenbook 13 10500 I want to ...
2
votes
1answer
44 views

Merge content of one file into another file by replace a function

I am working on a shell script which is getting data from another program and I am using that variable value to read the content from file keep appending to different files after some modification to ...
-1
votes
1answer
92 views

How to get last quarter in Bash Script

I have a script that gets the proper quarter but I need to get the (quarter - 1) quarter=$(($(($((10#$(date -d $year$month$day +%m))) - 1)) / 3 + 1)) Currently this returns 3, I need it to return ...
0
votes
0answers
75 views

How can I run multiple php file in a single shell file?

I have a .sh file from which I want to run multiple .php file. Here is my code: #!/bin/sh while true; do hr=`date +%k:%m` if test $hr -ge 00:00 -a $hr -lt 00:05 then ./test1.php ./test2.php fi ...
0
votes
2answers
86 views

motd - UNIX - AIX - different welcome screens for diff users

is it possible to segregate different motd files for different users ? So Admin gets a different message and others diff one....
3
votes
1answer
218 views

What does eval X=\$$i mean in UNIX?

I have a small script with the following lines echo mom,dad |awk -F, '{print $1,$2}' | while read VAR1 VAR2 do for i in VAR1 VAR2 do eval X=\$$i echo $X done done OUTPUT: mom dad ...
0
votes
4answers
72 views

Getting different parts of a line

Suppose I have a line of text as follows: I have a nice car Is there any way to get different words of the line at different positions individually (say, I want to get 'have' and 'nice' parts) ...