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 (1)

5
votes
2answers
728 views

How to make a temporary file in RAM?

I have a script that will pipe its output to |tee scriptnameYYMMDD.txt. After each cycle of the for loop in which the output is generated, I'll be reversing the file contents with tac ...
0
votes
1answer
6 views

I'm trying to deploy with git to a semi-managed vps, need to write a script to change owners

I'm trying to deploy my sites on my company's semi-managed vps server using this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps It ...
-1
votes
0answers
10 views

Making a secret to take contents of a file encode it and outputs to a file and to be able to decrypt the message [on hold]

Script names :make secret, read secret makesecret takes the content of the file msg-norm and encodes it and outputs the encrypted message to the file msg-mixed readsecret then decrypts the ...
0
votes
1answer
10 views

How to force decimal addition (#10) when adding numbers with a carry (octal issue)

How can I get 10#1$result to work correctly? When creating a calculator for adding two numbers I am adding together by transversing the digits from small to large. e.g. for adding 51 plus 51 I am ...
-1
votes
1answer
19 views

Command output to file, new lines at beginning

I'm rewriting some 20+ year old Unix scripts and I want the output to go to the screen and a file. I know this is possible with tee. Is there a similar command that stacks new lines on top, at the ...
1
vote
1answer
21 views

use mutt to send email through specific port on CentOS 7

What specific syntax do I use to get mutt to send an email through port 587 on a CentOS 7 server? For example, the sender is me@mydomain.com, the recipient is someone.else@someotherdomain.com, the ...
0
votes
1answer
20 views

Avoid conversion to scientific notation in awk

I have a csv file that contains hundreds of columns. I would like to subtract the value of a specific column from a static number and then print the entire line. The values of that column are long ...
0
votes
5answers
150 views

How to get current working directory? [duplicate]

I want to have a script that takes the current working directory to a variable. The section that needs the directory is like this dir = pwd. It just prints pwd how do I get the current working ...
0
votes
0answers
33 views

Ubuntu script not working as desired

http://bernaerts.dyndns.org/linux/74-ubuntu/309-ubuntu-dual-display-monitor-position-lost The above link contains an Ubuntu script to reset the second monitor position, however when used under ...
1
vote
1answer
22 views

how to compare a decimal value with a integer in shell scripting? [duplicate]

Could anyone please help me for comparing a decimal value with a integer in shell scripting? Example: i=1 j=1.2 if [$j -gt $i];then echo "growth" else echo "None of the condition met" fi Im ...
1
vote
1answer
20 views

Batch rename “case duplicates”

I have a folder on my Linux system that is cross-synchronized with other computers, some of them with Windows. The problem is that in that folder there are files that are "case duplicates", i.e. their ...
0
votes
0answers
17 views

Add extra parameter for text label or just echo it outside the call?

I have written a program that allows me to test my functions. I call it like this: do_test function_name expected_result parm1 parm2 For example do_test add_2_nums 10 5 5 Now I need to call the ...
-6
votes
0answers
30 views

Script for compare two file permissions

create dir, create two files with diff permission. Now write a script to test the permisiion of these two files. If its same then display the filename with its permission. if not display the ...
1
vote
1answer
50 views

Shell script runs diffrently based on working directory.

I have a script which runs differently based on current working directory. Basically it processes an .ini file and takes parameters from it and runs mysql backup. Script is running as root user. ...
1
vote
0answers
29 views

Why the output is not written to log from expect script

I am trying to write the output of the netcat command including the command also to a file by logging into remote servers. But it is not writing. What am I missing ? #!/usr/bin/expect -f set user ...
0
votes
2answers
51 views

how to save the contents of a webpage in a file using shell script

how to save the contents of a webpage in a file using shell script. Web page is using URL, username and password to open. curl -O odcview:password ...
2
votes
2answers
26 views

How can I copy and move a sequential subset of files?

I have a directory containing 1772 files named PRC0001, PRC002,... up to PRC1772. How can I copy a subset, for example PRC0257 to PRC1516 to a different directory? I am trying to do this for several ...
2
votes
5answers
210 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 ...
1
vote
0answers
20 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
27 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
264 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
72 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
23 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
79 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
124 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
181 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
106 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
507 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 ...
1
vote
2answers
31 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
15 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
34 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
53 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
37 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
52 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
58 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
22 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
30 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
114 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
284 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
186 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 ...
2
votes
2answers
65 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
26 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
35 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
95 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
66 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
54 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 ...
1
vote
3answers
268 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
35 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
26 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
38 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?