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)

2
votes
5answers
1k views

cut for key-value pairs

I am looking for an easy way to cut key-value pairs (where the key is unique and specified) from text, much like how cut can be used to cut a specified column in a CSV file. The keys I'm looking for ...
2
votes
0answers
62 views

programmatically alter kde file associations

Problem: In kde I want to remove a particular file association from every file type Details: I wanted to try out clamTk as a companion to clamAv. It didn't suit my needs so I uninstalled the ...
1
vote
1answer
72 views

Why do some apps leave KeyRelease events to be consumed by next focused app/window

I'm trying to wrap dmenu within some script to feed it input and act on it, however when pressing the Return key to select some dmenu input, a KeyRelease event gets sent to whatever window is focused ...
4
votes
3answers
683 views

Run command automatically when files are copied into a directory

I have two folders called: A and B, in different paths on the same computer. When I add any new file(s) into folder A, I want to copy it to folder B automatically. My folders: /auto/std1/nat1/A ...
0
votes
1answer
450 views

bash if, then and else statement

I am learning bash, I ran into a small problem when trying to write a small script #!/bin/bash clear read num if [ "$num" -eq 2 ] then [ -d "/etc/passwd" ] | sudo cp /etc/passwd /home echo ...
1
vote
1answer
33 views

Possible to deliver centrally configured login scripts on Linux?

In Windows you can assign login scripts to users which run whenever they log into a system which allowing admins to do things like map drives/printers and generally do anything for which there isn't a ...
1
vote
4answers
150 views

Script to delete files that don't match certain filenames

I have a folder with 500,000 images, sorted in subfolders by year and month. I'd like to create a script that does this: If the filename does not match any of the filenames in names.log then delete ...
2
votes
2answers
267 views

Bash menu with multiple parameters in one row

I have searched a couple of days and still didn't found the answer. I hope that you can point me in right direction. I would like to know how to write a bash script with a options, that can be ...
7
votes
7answers
207 views

What is the purpose of having two variables ($@,$*) to transmit the arguments of a command into a script? [duplicate]

I have read of the special variables used in a script $@ and $*. As far as I understand, the arguments used while executing the script are stored into two special variables, once all arguments into $@ ...
4
votes
1answer
120 views

print the content of files

I have a list of parent folders, sub folders and files inside the folders and the sub folders. I used the following command line to list the content of the parent folders and the sub folders: tree ...
6
votes
4answers
647 views

Why is it “while kill -0 $PID” and not “until kill -0 $PID”?

I may be being daft here, but if I want to do something while a process is running, why do I do: while kill -0 $PID do #... done instead of until kill -0 $PID do #... done ? kill -0 ...
2
votes
2answers
622 views

Script to backup home directory creating a compressed tar file in the /var/local directory

#!/bin/bash tar -czvf backup.tar.gz /home/administrator Having problems with making sure the file is created in the /var/local directory.
0
votes
0answers
26 views

Dual partition scheme with GRUB

I would like to use a dual partition update scheme for some servers like CoreOS is doing here. Basically the process is the following: The computer has partition A and B, each with a full Linux ...
1
vote
1answer
50 views

Saving result between script executions

I have a script in /opt which is called regularly by Cron. The script needs to write and read a status flag between executions. In what directory should I store the flag? I'm thinking that /tmp might ...
2
votes
1answer
293 views

ssh and run script on remote host and answer expect answer automate

The ssh from server0 to (server1,server2,server3) (no password need to SSH (trust exists between all servers and private key exists on all servers)) but a remote script on server (server1,server2 ...
0
votes
1answer
43 views

bash: getting integer expression expected

Here is the piece of code that gives the problem: if [ " ls -l ~/sysbackups | wc -l " -gt 5] What to do?
0
votes
1answer
126 views

Run a Vim command from a bash script

This is related to a question I asked earlier but I would like to keep it separate in case anyone else can find use in it. I have a command that I am running on a file called dummy.out from the ...
2
votes
2answers
107 views

Bash Scripting VIM commands

I have a few files that I have an annoyingly repetitive group of VIM commands to apply to. They are basic VIM commands just to delete some lines which are not supported by the process I need the files ...
1
vote
1answer
91 views

Auto-start multiple background user sessions in Linux Mint

I could use some help with what I think is a basic request on the newest edition of Linux Mint (which I think would also be applicable to Ubuntu). I have a home system with 3GB of RAM and accounts ...
1
vote
1answer
135 views

value too great for base (error token is “08”)

Trying to do quiz 'max sum of 2 from grid' Can't figure out how to get around the error below. Feels like I'm missing something. Once I find out what I can update the question to be more general ...
2
votes
3answers
201 views

Processing input line by line (with empty lines) from shell

In a shell script, I need to parse the output of a command line-by-line. The output may include empty lines, and these are relevant. I am using ash, not bash, so cannot resort to process substitution. ...
1
vote
3answers
663 views

Read longest line in file using while read loop?

I've been googling but I can't find any scripts that uses the while loop to read the lines. I'm stuck and I'm not sure on where to start Heres the question: Write a bash script longestline.sh that ...
2
votes
3answers
284 views

What is the purpose of a start up script? [closed]

So far I know the basic meaning of a script, it is a file containing shell-commands made executable by chmod +x file and able to be run by ./ file. My friend told me, he had to copy so called start ...
3
votes
2answers
82 views

What do i have to consider to write a script that reacts on a keypress?

I know i can read within a script something into a variable, like this: variable = read But i have to press enter in order to submit the value into the variable. What do i have to know in order to ...
1
vote
0answers
52 views

Service script and shared libraries

I have the following simple script IPN in CentOS 6.5 in /etc/init.d/ #!/bin/sh # chkconfig: 2345 05 06 cd /root/IPNHost . /etc/rc.d/init.d/functions start() { echo -n $"Starting..." ...
0
votes
1answer
149 views

Python script: wait until job in tmux session has completed

I am trying to continuously run a python script with random parameters from another python script, where each run is in its own tmux session. A very simplified overview of what I'm trying to do goes ...
2
votes
6answers
183 views

Scripting to split a single CSV row into multiple

I need a script that can take a CSV file with that has a column of semicolon-delimited attributes, and break it into multiple rows to normalize that multi-valued attribute? Here is the scenario: ...
0
votes
1answer
150 views

How can I use a linux shell script to change directories and copy files?

There are several files I need to copy which are stored in different directories. The file names will all have two common fields that are distinctive for a particular date and time. I can usually ...
0
votes
5answers
120 views

How to Read string from file and compare to each line of second file

I'm making the post OS installation script that will include the Hardening section . And in this hardening section it will read the Kernel parameters from file A and compare to file /etc/sysctl.conf ...
2
votes
3answers
284 views

How can I pass on parameters 4..99 to another function

I'm calling a function and I want to pass up to 100 paramters onto another function. I do not want to pass on the first 3 params, I start with param4 being the first param for the other program. I ...
0
votes
2answers
44 views

script for substition incremental

I have 4 machines, every machine(centos) has a ifcfg-bond1 with identical ip address 10.0.0.3 How to using bash and sed substituting 10.0.0.3 with a incremental value? I want to obtain something like ...
0
votes
0answers
38 views

How to extract data from the file

How can I extract data from "config.tab" files located in different directory and put it in a single text file. Example: /servers/FRCOLP0056673/config.tab /servers/FRCOLP0056674/config.tab ...
-1
votes
1answer
198 views

What is the best site or book for practicing shell scripting? [closed]

I have learnt shell scripting basics from internet, bash scripting guide and other resources. But now I want to practice shell scripting, can you please guide me where can I find good problems?
1
vote
3answers
231 views

Shell script to find and count total number of characters in all the files

How can I make a script that finds every file in your home directory that is less than 3 days old and then gets a count of the total number of characters in all of these files?
2
votes
2answers
81 views

Is it better to use a shebang line to execute a script?

I was looking up shebang and wondering why I would use it. I could execute a bash script using: bash foo.sh or ./foo.sh (with a shebang line in foo.sh) What are the pros and cons of each and ...
0
votes
3answers
148 views

Hostname variable doesn't work

I'm on a Raspberry Pi using RPiTC (Raspberry Pi Thin Client). I had made a script with an Hostname variable. It's worked perfectly but today when I had launch my script I saw something strange. My ...
0
votes
2answers
51 views

Locate specific file from script

I've written a script file in which, one function searches for another script and if found, executes that script. Script extract #!/bin/bash ... service_status() { local my_script=`which ...
2
votes
3answers
117 views

Can you make a process pool with shell scripts?

Say I have a great number of jobs (dozens or hundreds) that need doing, but they're CPU intensive and only a few can be run at once. Is there an easy way to run X jobs at once and start a new one ...
1
vote
2answers
649 views

script that lists all files in a directory and subdirectories sorted by size, listing only file names not complete paths

I'm looking for a script that lists all files in a directory and subdirectories sorted by size, listing only file names not complete paths. find . -type f -exec ls -lhS {} \+ works but gives the ...
0
votes
1answer
44 views

finding and replacing text [duplicate]

Does any one know how to find and replace text in a file. it can be implimented into a bash file. i would like to find the line and the output the text to it the file can only be opened with the root ...
0
votes
1answer
49 views

Universal .bashrc alias showing results of sysytemctl start command

This is small .bashrc alias that allows me to see results of starting service alias systemctl start apache='systemctl start apache && echo SUCCESS || echo failure' How can i modify to work ...
0
votes
1answer
12 views

How can I pass a function name to a test runner?

I wanted to write my own test runner: do_test () { function_under_test=$1 expected="$2" function_under_test $3 # <-- Line 32 if [ $result -eq $expected ]; then printf '.' else ...
1
vote
2answers
255 views

Why do I get Illegal number: {1..3}

Why am I getting ./6_sum_square_difference.sh: 11: ./6_sum_square_difference.sh: Illegal number: {1..3} for #!/bin/sh summing () { the_total=0 num_in=$1 for one_num in {1..$num_in} do ...
2
votes
1answer
247 views

Easy command line method to determine specific ARM architecture string?

I'm trying to write a script which will determine actions based on the architecture of the machine. I already use uname -m to gather the architecture line, however I do not know how many ARM ...
0
votes
1answer
66 views

Why does this comparison return not equal?

Can't seem to get this to evaluate to true is_equal () { in="$1" if [[ "$in" == "385" ]]; then return 0 else return 1 fi } a= is_equal 385 if [[ "$a" ]]; then echo "equal" else ...
0
votes
0answers
99 views

Increment Numbers in URL?

I want to create a list of URLs. The URLs have two sets of identical numbers which need to be incremented by 1: http://sample.com/poilus/cwrgshs/192/192.html ...
-1
votes
1answer
65 views

Check exist file on another pc

Yesterday I had ask how to use my tftp protocol in my bash script: Debian - Using TFTP in a bash script And now I have a problem with my tftp protocol. The file who was taken depend of my Hostname. ...
0
votes
1answer
405 views

Debian - Using TFTP in a bash script

I'm actually using RPiTC (Raspberry Pi Thin Client). I had create a script to see if my Hostname has the same name than a file. And now I want to say "If my Hostname don't have the same name than my ...
0
votes
2answers
44 views

Multiply a column using awk

How do I multiply a column by an integer (say 3) and replace the older value by new one, using awk? Input: Data 9390.900391 10573.089844 80.000000 200.000000 2.700000 Data ...
-2
votes
2answers
51 views

How to use shift to shift $@ one over

I am running a shells script with 3 arguments. I am getting the word count of each one. But I want to skip over the very first argument, maybe by using shift or something else. Most of the examples ...