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)

2
votes
3answers
62 views

How to get whole command line from a process?

How can I get the command arguments or the whole command line from a running process using its process name? For example this process: # ps PID USER TIME COMMAND 1452 root 0:00 ...
0
votes
0answers
34 views

How can I merge a list of spreadsheet?

I have a list of spreadsheet files consisted of columns and I wanted to merge them in one file and organize the columns in the output spreadsheet as the following: spreadsheet A spreadsheet B ...
1
vote
3answers
77 views

How to sum match numbers

I'm new at scripting, and need some help. Will appreciate your answers. I got this assignment, which is to find the sum of all five-digit numbers (in the range 10000 - 99999) containing exactly two ...
1
vote
1answer
9 views

Locating the terminal currently in use

I need to write a script to test if im using the correct terminal and then print a message This is what i have so far if(???? == dev/pts/1) echo Access Granted. Welcome. endif I dont know how to ...
7
votes
3answers
239 views

How can a Bash script tell how it was run?

I have a Bash script I was trying to make to help me run a rather complex command with small changes that it would ask me about through echo and read. I have found solutions to force it to run a ...
1
vote
2answers
53 views

How can a script run many processes at the same time?

I want my code to run many processes at the same time. The following example for a code and the source is StackExchange (Unix&Linux ) web site. > #!/bin/bash > for i in $(cat lis.txt); do ...
0
votes
0answers
40 views

cronjob executes every minute but should execute every hour [on hold]

I have a script which should be executed every hour, which creates a new log file. But it executes every minute. I am really despairing. My entry in crontab -e looks like this: #Create new logfile 0 ...
0
votes
4answers
79 views

Create a list of directories

I have a list of names in a text file (list.txt) I want to create a list of folders for the names included in that file. I wrote the following script, but it doesn't work and I don't know what is ...
0
votes
0answers
10 views

auto installing dropbox daemon(dropboxd) with profile signed in automatically script issue

I am trying to install dropbox automatically in my server auto-install script so when I spawn a new VPS instance I'm able to have dropbox installed and have the credentials already inputed via the ...
1
vote
2answers
54 views

Check that a bash script has exactly two arguments which are directories

I'm writing a bash script that compares two directories, but I'm not sure how to check conditions For example, if the user enters 1 arg instead of 2 (we need 2 since we're comparing two directories), ...
4
votes
2answers
170 views

Run script in a screen

I want to run a bash script in a detached screen. The script calls a program a few times, each of which takes too long to wait. My first thought was to simply open a screen and then call the script, ...
2
votes
2answers
49 views

How can I make a for loop starting a lot of processes?

I want to test some bug, and to do that I need to have a situation where the PID is larger than 99999. I am thinking of a bash script, a for loop. Any ideas?
0
votes
1answer
26 views

Another unterminated 's' command

I am trying to make a simple replacement for an IPv4 address script. sed "s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/192.100.100.100/g" This is what I have. As stated in the title I ...
2
votes
2answers
51 views

Compare 2 delimited files and output differences

I have asked similar questions here a couple times in the past with great success, but now my needs have slightly changed and I am struggling to get the exact output I am looking for. I would like to ...
1
vote
3answers
121 views

bash script that reads user input and uses “cal” command to validate dates

I want to write a script that reads my input (for example if my script is called "check", then I would type "check 9 4 1993" and that input would go through the cal command and will check through the ...
1
vote
1answer
67 views

One-Click Script to Gmail Yourself a File

Does such a thing exist? I'd be interested in something like: You right-click a file in a file viewing manager, and click "gmail yourself this file". One click, and you're done. You open up the ...
0
votes
1answer
23 views

Shell script permission denied despite +x flag

This is an odd one, it only happens on one server (shared hosting, so I have limited access to configuration and logs), but I can't wrap my head around it. I have a shell script which runs some app's ...
1
vote
1answer
26 views

View timestamp for CUPS print jobs

I'm looking for a way to view the timestamp of a job in CUPS. I've searched the man pages and can't seem to find it. The long term goal is to have a script that parses the time from the jobID and ...
2
votes
1answer
42 views

Using rsync to copy from local to remote server with cronjob, asking for password

I want to copy files from a local machine to a remote machine. I have the command all set up and it looks like this: rsync -a project root@123.456.789.0:~ However, when running this command, I'm ...
-1
votes
1answer
62 views

just wanted to know what am i doing wrong in the end of this script that doesnt put my checkdate in to cal command

#Purpose: Validate a date #Usage: chkdate year month day # if [ $# -eq 0 ]; then echo Usage: chkdate year month day exit 0 fi year=$1; month=$2; day=$3; extra=$4 if [[ "$extra" != "" ...
12
votes
2answers
503 views

How does awk '!a[$0]++' work?

This one-liner removes duplicate lines from text input without pre-sorting. For example: $ cat >f q w e w r $ awk '!a[$0]++' <f q w e r $ The original code I have found on the internets ...
1
vote
1answer
41 views

How to write this replacement with condition

I want to replace now within my working directories the word -> with $\to$ if the word is not within verbatim environment. Pseudocode Replace all entriens of -> with $\to$ everywhere else but not ...
8
votes
2answers
493 views

How to non-invasively test for write access to a file?

In a shell script, how do I easily and non-invasively test for write access to a file without actually attempting to modify the file? I could parse the output of stat, but that seems really complex, ...
2
votes
1answer
178 views

How to remove file log with file name

Assume, I have log files with this name format. NameLog.log.2014-09-27 NameLog.log.2014-09-28 NameLog.log.2014-09-29 NameLog.log.2014-09-30 NameLog.log.2014-10-01 NameLog.log.2014-10-02 ...
3
votes
2answers
88 views

How to write this pseudocode where condition

This question is extension of this question about listing questions of directories. I get a problem that I need to understand the original section of the text. Current output where you see the ...
1
vote
1answer
34 views

ffmpeg script - slicing a video into multiple slices

I am currently using ffmpeg to slice video files. I automated the process through a script called ffmpeg_split.sh. To view the script click here. When I run the script I have an error when trying to ...
0
votes
2answers
50 views

copy and rename script

Directory A: 1111111_1.pdf 2222222_1.pdf 1234567_1.pdf Directory B: abcdefg.pdf zzzzzzz.pdf 1234567.pdf 1111111.pdf 2222222.pdf ...
6
votes
2answers
364 views

What is the reliable way of getting each user's .ssh directory from bash?

I can parse the /etc/passwd with augtool: myuser=bob usershome=`augtool -L -A --transform "Passwd incl /etc/passwd" print "/files/etc/passwd/$myuser/home" | sed -En 's/\/.* = (.*)/\1/p'` ...but it ...
1
vote
3answers
58 views

I want to divide a sum of numbers by a value

So here is my code for Unix shell scripting #! /bin/ksh echo "Enter your first number:" read first echo "Enter your second number:" read second echo "Enter your third number:" read ...
4
votes
2answers
125 views

When is 'if' not necessary?

In some scripts, I've seen if conditional statements written as: if [ some_conditional_statement ]; then # do stuff fi or [ some_conditional_statement ] && #do stuff Is the second ...
3
votes
3answers
183 views

How to copy, execute and retrieve data from a remote computer?

I am trying to run some calculations on a remote computer. Basically I want to copy some files to the computer, load a software, execute the calculation, then retrieve the data back. I have created a ...
2
votes
1answer
33 views

Interacting with webpage through script?

I have an email-account where I've ended-up with a lot (200 000) of messages in the Spam-folder. Unfortunately, it's not all spam - partly due to badly trained filter and partly due to mail-list ...
2
votes
3answers
74 views

How to sum times in a text file using command-line?

I have a text file containing flight times, hours and minutes separated by colon sign, one per line: 00:50 00:41 00:43 00:50 01:24 I am currently using Apple's Numbers application with a simple ...
0
votes
2answers
25 views

merge mutiple files using common column [duplicate]

Say I have multiple files x1, x2,x3,x4, all with common header date, time, year, age. How can I merge them to one singe file X in shell scripting? File x1: date time year age 101014 1344 2012 52 ...
2
votes
2answers
43 views

Interacting with a running interactive console program from a different process

I have a console program with an interactive shell, similar to say, the Python interactive shell. Is there an easy way to start this interactive program A and then use another program B to run A? I ...
2
votes
1answer
52 views

Get the full window dimensions (including decorations) in Unity

I have used the answer to How do I find the window dimensions and position accurately including decorations? in my bash scripts, and had good success with my Silentcast application on Xfce, but now ...
0
votes
0answers
22 views

Can't set PATH with a script [duplicate]

I have written a script which was supposed to add some value to environmental variable PATH, but script doesn't do that if I start it with ./script.sh. #! /bin/bash INSTALLDIR="/opt/ARM" ...
6
votes
1answer
200 views

How do I print all but the Nth to last line in sed?

I'd like to do the complement / "opposite" of sed 13q;d <file.txt More generally, is it possible to do this sort of complement/inverse/opposite in sed? Or only for regexes? How do I print all ...
1
vote
0answers
38 views

Maintain screen session when executing shell script on boot

On Ubuntu 14.04, I have a crontab entry set to run on reboot: @reboot /root/start_server.sh And here's start_server.sh: screen -dmS server bash -c "cd server ; ./run.sh" When the system starts ...
1
vote
3answers
46 views

Find a string in one section of a file with mutiple sections

How to sed/awk for a string contained in another string. TESTVAR=' { icon : "icons/773_l.png", id : 80, initialState : true, isPng : false, label : "Imagery", opacity : 1, requestType : ...
1
vote
1answer
53 views

Is it possible to create a Linux environment without a traditional command shell?

i.e. Using something like IPython, re.pl, or somesuch as a login shell, instead of bash/ksh/etc. Using initscripts, etc. written in Python or some other scripting language, and making no use of ...
0
votes
2answers
34 views

7z from bash script won't exclude directories

I've encountered with kinda strange behaviour of 7z (or bash, I don't know yet.). With the following script: #!/bin/bash find /home/user -type f -name "*.pdf" | cut -c 10- > ...
1
vote
1answer
30 views

how do you include variables in Bind9 configuration files?

I am trying to create a auto install script since I have to do this installation task on multiple servers. I have setup all the bind9 configuration files with my variables and thought it would have ...
1
vote
2answers
64 views

Concatenate file contents AND names

I've been writing for many months. The files I create are dated files named like 2011-06-13.markdown with daily content. I've decided I want to have all the writing in one file instead but I'd like ...
1
vote
1answer
77 views

Why are UNIX shells like this and how can I work around it?

One of the things I've noticed about BASH and other UNIX shells is that, by default and when used in typical ways, they spawn subshells for almost everything. e.g. foo=$(grep "someword" ...
0
votes
0answers
17 views

Is there a version of script that plays nicely with vim?

man script says: Certain interactive commands, such as vi(1), create garbage in the type‐ script file. Script works best with commands that do not manipulate the screen, the results ...
0
votes
1answer
45 views

Telnet no echo output from xinetd script

I have have installed xinetd, and I wrote a script: #!/bin/bash echo "Some text" touch /home/somefile I made a service configuration under /etc/xinetd.d/ and basically it works when I connect to ...
0
votes
2answers
44 views

Bash script: test command -o option

I have a piece of code like this: count=0 until [ -f $filename -o $count -ge 60 ] do count=$((count+1)) sleep 1 done I know [ -f $filename -o $count -ge 60 ] is a test command, "-f $filename" ...
3
votes
1answer
30 views

More shell scripts than one in one text file?

I am learning shell scripting for my introductory UNIX course at my university, and I`m curious if is it possible to have more than one shell script in one text file. What I mean by that is, for ...
3
votes
3answers
162 views

Having an issue searching for a string in a file

I have tried to use a 'case' loop but it doesn't work for a reason unknown to me. This is my script for the case loop. echo "Do you wish to search again? [y/n]" read INPUT_STRING2 case ...