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)

3
votes
1answer
139 views

Script to find the default Desktop Environment?

Assume a Linux Desktop Environment system is installed. When powered on and credentials entered, whatever Desktop Environment is started i would consider the default Desktop Environment. The user may ...
3
votes
1answer
218 views

Why is expect's interact command not working?

I am trying to automate gdb with expect. My script will start gdb, do some initialisation, and then pass the control to the user. Expect's interact command seems like the perfect tool for the job. ...
3
votes
1answer
236 views

Extract single file from tar to other folder

I've searched for multiple forums for this questions and have seen different answers but so far, nothing have worked yet even from the ones I've seen here. I want to extract a single file from a tar ...
8
votes
3answers
246 views

rsync most recent x GB

I'm looking for a command/script to allow the most recently modified files (up to) 10GB be copied to another computer. So if there are 4 files 4 GB each, only 2 of them should be transferred by the ...
2
votes
1answer
77 views

tar and if-statement

I have a script that check if a file exist inside a tar file but something's wrong because it always go to the else part of the script. I am pretty sure that it shouldn't be that way. The date is in ...
-1
votes
1answer
45 views

A triangle of forward differences in gawk

I need a gawk script (not a one-liner, I need a function). Given a row of integers i.e. 0 2 4 1 9 5 1 1 the function should generate successive forward absolute differences, so: 0 2 4 1 9 5 1 1 2 ...
0
votes
0answers
25 views

Variable Substitution in sed [duplicate]

I have this script and I need to count the lines inside a file, then pass the number of lines counted to a for loop so that I can get the contents of each line and put it in a variable. My question ...
3
votes
3answers
276 views

How to put fixed-width, vertically-oriented key-value pairs in a CSV file?

I have a text file with the following type of content: OPERATION_CONTEXT VMD1HTE1A71_ns:.oc.GJ_OAD2 alarm_object 1130 On director: VMD1HTE1A71_ns:.temip.VMD1HTE1A71_director AT Fri 18 Oct 2013 ...
0
votes
2answers
136 views

Formatting quotes from the fortune to use it with conky

I'm using fortune cookie outputs in my conky script. My fortune output is in the following format: Text1 : Some message including( line break tags, e.g. and comma(,),=,semicolon(;) like ...
1
vote
1answer
185 views

How to see interactive output when running commands from a bash script?

I'm trying to run some commands from a Bash script, that when Enter is pressed should give some output. An example is nmap. When calling a few different nmap scans from a Bash script, pressing Enter ...
1
vote
2answers
116 views

Get exit code of command executed by the linux script command

Note this is run on a debian linux environment I have the following sample script called HelloWorld.sh #!/bin/bash echo "Hello World" exit 1 I then run the following command script -c ...
3
votes
0answers
51 views

Notifying program that X session is shutting down

Ok. I understand X session is a bit vague here so let me clarify what I mean by the phrase. I mean the situation where a person has been presented with a display manger screen ( eg xdm, kdm, gdm, mdm, ...
2
votes
1answer
45 views

How do I drop to a shell after exiting a command I started by scripting tmux?

I'm following this tutorial for scripting the creation of tmux windows. tmux new-window t $SESSION:0 -k -n MAIN 'cd ~/main/ && perl -Ilib myapp' sometimes I kill myapp after I've started ...
2
votes
5answers
146 views

Delete all files in directories except those whose path are listed in a file

Given the following files: data/A/a.txt data/B/b.pdf ... date/P/whatever.log ... data/Z/z.jpg I would like to delete all files in the data/A/, data/B/, ..., data/Z/ directories except those files ...
9
votes
3answers
546 views

Advice for managing SSH keys

What is the best practice you have found for managing lots of SSH keypairs? I use SSH to connect to several systems, both at home and at work. I currently have a fairly small, manageable collection ...
3
votes
2answers
98 views

Running commands after event based outputs

there are commands like iwevent or tcpdump -n src host x.x.x.x that send to the stdout some lines when something happens. Is there any form of running some command inmmediatly after a ...
0
votes
1answer
74 views

Checking mail and running a script without downloading

I'm writing a script to run certain processing activities (mainly moving some data files to another machine where they can backed up), but I only know when to trigger the copy when a mail is delivered ...
0
votes
2answers
64 views

Run level script - Help

I want the following command to be ran, as soon as system boots. glances -s -P redhat & How to achieve that? I tried writing a run level script which didn't work as expected.
1
vote
1answer
119 views

Script ends abruptly with a Terminated message

This is my bash script. All it does is to check whether a service has started and whether some processes are running as expected. It ends abruptly with a Terminated message. I tried debugging it ...
4
votes
1answer
54 views

How can I get information about my virtual desktops via the command line?

I'm curious how I can get information such as the dimensions of my desktop, which desktop is currently active, and what labels (if any) are set for my desktop enviornment (DE).
2
votes
3answers
125 views

Concatenate files in multiple matching subdirectories

I need to concatenate files based upon the name of the subdirectory they are in. The subdirectories sometimes have duplicates and sometimes don't. The file structure looks like this: RootDir 633 ...
-1
votes
2answers
67 views

Make a new sniffer [closed]

How can use the Linux-kernel to supervise what is going on, about the new connections, new ports, connected hosts? Like I will do a new sniffer. Which files should I monitor to know what is going ...
4
votes
1answer
261 views

How to set firefox homepage from terminal?

I am trying to configure firefox from a script. I have already hit a wall establishing the deafault homepage. Found some old info what does not work anymore: echo ...
9
votes
2answers
2k views

Regular expression in bash script

This is my first time bash scripting so I'm probably making an easy mistake. Basically, I'm trying to write a script that gets the groups of a user, and if they are in a certain group, it will log ...
2
votes
2answers
198 views

Optimized way to list and delete files

I need to list and delete .php, .xml files. For this I am using find command. To list : find . -type f -name \*.php -print0 To delete : find . -type f -name \*.php -print0 | xargs -0 rm -r As I run ...
6
votes
2answers
357 views

How does this find command using “find … -exec sh -c '…' sh {} +” work?

@StephaneChazelas posted the following solution to this Q&A: Having some trouble using “find -exec {} +”. $ find . -iname "*.extension" -exec sh -c ' exec <command> "$@" <additional ...
2
votes
2answers
108 views

Sanitize Apache access log files?

We have this code in a shell script that pipes output for Apache to log. declare -a values=( $taintRequestVals ) for item in ${!values[@]} do cat $apacheLog | sed ...
2
votes
2answers
4k views

how can I add (subtract, etc.) two numbers with bash?

I can read the numbers and operation in with: echo "First number please" read num1 echo "Second mumber please" read num2 echo "Operation?" read op but then all my attempts to add the numbers fail: ...
2
votes
2answers
224 views

How to copy multiple files but keep their extensions the same?

I am looping through a number of files, and $file represents the current file. How can I make copies or renames and keep the extension the same for this current file? e.g. if $file = x.jpg How to ...
1
vote
3answers
99 views

How to add Multiple Searches in AWK command

Im trying to search for the files Created in June,July and August months. I used this method ls -lrth|awk '/[Jun][Jul][Aug]/ {print}' but it ain't working. Please help me correct the syntax.
2
votes
3answers
209 views

Analyzing tricky one liners & having handy list of useful ones

Have seen one liners like below & took a little time to analyse exact use & working of it – something like set the value to later one if it is not set. export ...
1
vote
2answers
68 views

(Ill)Logical statement

I am attempting to make a simple script to flip my computer screen. My first if statement executes perfectly, but after that, thought $istouch is "on", the elif statement block will not execute! I ...
2
votes
1answer
75 views

Regular Expressions within a string in AWK using if/then control structure?

PROBLEM I want to specifically use AWK (GAWK, MAWK, whatever) in an AWK script to sum up the values in field 9 for every record that contains "runner__.jpx" (the underscores are placeholders for two ...
0
votes
0answers
8 views

Removing in interactive mode [duplicate]

I want to create a script that whenevr there are more than three files being removed, it invokes rm -i by default, i know it will go in initialization files but cant seem to get it working.
0
votes
4answers
76 views

Create a duplicate record based on a condition

I need to write a shell script where I have to create a duplicate record based on a condition and then change the value in a column of the new row which will be created. I am trying to create a ...
1
vote
2answers
285 views

Bash shell scripting basic question regarding the syntax and basename

Consider the script below: myname=`basename $0`; for i in `ls -A` do if [ $i = $myname ] then echo "Sorry i won't rename myself" else newname=`echo $i |tr a-z A-Z` mv $i $newname fi done ...
5
votes
3answers
329 views

Maintain (or restore) file permissions when replacing file

I have a command that accepts a file as an argument, modifies the file, then writes it to the file name specified in the second argument. I'll call that program modifyfile. I wanted it to work "in ...
4
votes
3answers
750 views

Summing up an array inside of awk?

I have the following piece of code: sum1= sum2= declare -a a echo $temp | awk '{split($0,a,","); name=a[1] ; for(i=2;i<=4;i++) sum1+=a[i] ; for(i=5;i<=7;i++) sum2+=a[i] }' This code is ...
2
votes
1answer
66 views

Configure add-to-tranmission-daemon-action in firefox?

How do I configure firefox such that a clicked bittorent link is automatically added to a transmission daemon that runs on a remote machine? The transmission daemon is available via ...
2
votes
3answers
694 views

Shell script to validate mount point status in the linux server

I'm in need of a script which should work as below. A script where it would validate if that specific mountpoint is currently mounted on the server. It would search for mountpoint name in /etc/fstab ...
2
votes
3answers
87 views

Using sed to insert latex commands around headers of a document

I have a documen with headers in ALL CAPS, for example: NAME env - run a program in a modified environment and I want to insert \item[ before the header and ] \hfill \\ after a header ...
3
votes
1answer
127 views

How can I write a sed script to delete numbers from a line?

Sample File a.b.gg3d 0000000001 0000000001 y a.b.112a 0000000000 0000000001 y a.b.gg3s 0000000001 0000000001 y a.b.1111 0000000000 0000000001 m I have a file that includes about three thousand ...
0
votes
1answer
235 views

How to run a shell command in a server?

I am fairly familiar with computers and web stuff but this is a bit out of my comfort zone. I have a shell script (.sh file) I want to run in a Linux server I have one site hosted (the script is a ...
2
votes
1answer
1k views

bash: integer expression expected

I have a file out.csv I have to check if the name inputed by user exists in the file(comma separated) or not. I am taking name using read but while checking for equality I am getting error ...
1
vote
2answers
53 views

How can I merge multiple lines with spaces (blank line) separating them? [closed]

I'd like to merge the following multiple lines of output so that they form a single line: line 1: ...
3
votes
2answers
274 views

How to get volume level from the command line?

I have a text status bar on a tiling window manager and I am using tcl to feed information to it. At the moment I need a command line that output the volume level 0% to 100%. I am using Arch Linux.
5
votes
2answers
203 views

Launching an external script with source command

I've been learning shell scripting, by reading good tutorials and reading scripts. I was reading this minecraft init script, and these first lines hit me: if [ -L $0 ] then source `readlink -e ...
1
vote
3answers
148 views

how to calculate the average value of the column that have the row ID?

I want to calculate the average value of my data when they have the same ID (in my specific case, the same day but different time in a day). This is meant to calculate the daily average value of my ...
0
votes
3answers
69 views

how to run more than one program in a single script?

I have about 6 programs I want to run one after the other. They all are in different directories with their respective data. I would like help with a script that I can use to run each program in a ...
2
votes
2answers
63 views

open a file and copy the listed files to another folder

I have a file named file1.txtcontaining file names like below : filea.txt fileb.txt filec.txt I want to copy the files listed in file1.txt to another folder. What is the UNIX command to use? (the ...