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)

6
votes
2answers
2k views

bash: Piping for loop output prevents local variable modification

First off, sorry for the title. I'm not sure of the correct terminology so if anyone can improve upon it that would be good. I am trying to write a simple bash function that takes, as it's arguments, ...
5
votes
4answers
160 views

Prefixing and appending blocks of text to a list of files

I'm trying to prefix and append blocks of text to a list of files. Here is where I am so far. The sticking point is the sed -i "1i \$prefix" "$file" && line. sed won't substitute the value of ...
5
votes
5answers
3k views

Parsing a delimited text file in bash as command arguments

I have a text file split up like so: field1,field2,field3 xield1,xield2,xield3 dield1,dield2,dield3 gield1,gield2,gield3 Each of these columns will be a parameter to a program, and I would like ...
3
votes
4answers
1k views

passing passwords to a script

I want to scp a file to a remote host, and from there, run a command on the file, and exit the remote session. If I write a usual script, call scp and then ssh, I am prompted to enter two passwords. ...
2
votes
1answer
897 views

Shell script filtering through jpg files attributes

I'm trying to find a way to filter through thousands of jpg files, and keep only the files with a certain attribute (such as the camera brand with which the picture was captured). How can I do so?
10
votes
2answers
5k views

Confusing use of && and || operators

I was skimming through an /etc/rc.d/init.d/sendmail file (I know this is hardly ever used, but I'm studying for an exam), and I've become a bit confused about the && and the || operators. ...
8
votes
2answers
6k views

Invert boolean variable

I want to try simple script flag=false while !$flag do read x if [ "$x" -eq "true" ] then flag=true fi echo "${x} : ${flag}" done But when i run it, if i type true, i will see ...
7
votes
2answers
918 views

sync files recursively between two folders where files are less than 24 hours old

I want to find all the files under a directory which are within 24 hours then rsync those files with another server. There are some old files that I do not want to transfer, however if those old ...
7
votes
6answers
5k views

Extracting nested zip files

I have numerous zip archives, each of which contains a number of zip archives. What is the best way to recursively extract all files contained within this zip archive and its child zip archives, that ...
5
votes
3answers
3k views

The way to use `/usr/bin/env sed -f ` in shebang?

Typing /usr/bin/env sed -f in terminal works. But if use it as a shebang, #!/usr/bin/env sed -f s/a/b/ The script will be fail to execute: /usr/bin/env: sed -f: No such file or directory I ...
4
votes
1answer
63 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).
4
votes
2answers
403 views

Is there a way to simulate a “Close” event on various windows using the terminal?

I answered on Ask Ubuntu Quit all instances of gnome-terminal via a command but as you all can read gnome-terminal didn't seems to have a SIGcall I could use to simulate this "Close" event. So this ...
3
votes
5answers
213 views

How can I force a script to use more resources?

I'm running a very time-consuming script which takes many hours to end. Watching top I see that it's only taking 5% of the CPU at best, usually around 3%. Is there any way to force the script to use ...
3
votes
3answers
185 views

Permissions for a submission script

I'm a TA for an introductory Python programming class (all work is done from the terminal), and I'm writing a project submission script. Ideally I want a directory setup like this: submissions/ ...
3
votes
2answers
592 views

Convert a typescript file to a list of commands (history)

I wanted to record a linux session so I could use it as documentation for a "how to install" guide. I found something on the internet that suggested that the script command would be good for this, and ...
2
votes
3answers
379 views

Extracting characters after a particular text

I am extracting a page from website using cURL command. curl "www.google.com" -s | w3m -dump -T text/html > foo.txt The w3m command outputs the HTML page in a much more simpler format so that ...
2
votes
2answers
900 views

Concatenate multiple files under subdirectories

My directory structure is given below x:\Project_2012-158A\Sample_4041 SampleSheet.csv 4041_CGTACG_L002_R1_001.fastq 4041_CGTACG_L002_R2_001.fastq 4041_CGTACG_L006_R2_001.fastq ...
2
votes
3answers
1k views

Anacron job complains “Gtk-WARNING **: cannot open display”

I'm trying to make a simple weekly Anacron job that backs up my computer if I click yes on the dialog. The script I wrote works fine if run manually, but when Anacron runs it, nothing happens and I ...
1
vote
2answers
67 views

How to notice log file changes with Linux standard tools? [duplicate]

I need something that does not need to be installed. It's on an embedded system with very little space on the HD. I can't instal anything. I need to do it with something that is already included. I ...
1
vote
2answers
793 views

How can I queue processes?

I have a surveillance camera and a program records videos when motion is detected. Basically, this program saves the video in a very heavy format. My solution was to call a script that converts the ...
7
votes
1answer
859 views

Problems running python script from motion

I'm trying to set up the raspberry pi with my webcam as a motion detecting cctv that uploads the videos to google drive using Jeremy Blythe's script I have motion working correctly and the python ...
5
votes
3answers
179 views

How to iterate through a list of files with spaces that is sorted (case insensitive)?

I am doing this in OSX which uses bash but obviously, not all bash conventions are used so hopefully your suggestion is available to me :) I have the following files fun bar1.txt Foo bar2.tXT ...
4
votes
3answers
150 views

shell script problem with using the operators

I am comparing two strings using the levenshtein distance algorithm. I got the PHP implementation of the algorithm from here. I am calling this php implementation from my shell script as below. ...
4
votes
2answers
206 views

Exiting a pipeline if a former command fails

I'm trying to check the number of running and queued PBS jobs by parsing the output of qstat -tn1 from a bash script. So far, this has worked: count () { qstat -tn1 | awk ' BEGIN { R = 0; ...
4
votes
4answers
4k views

Can IFS (Internal Field Separator) function as a single seperator for multiple consecutive delim chars?

Parsing an array using IFS with non-whites space values creates empty elements. Even using tr -s to shrink multiple delims to a single delim isn't enough. An example may explain the issue more ...
3
votes
4answers
1k views

Replacing text from a list of replacements. Added complication: backslashes

I have a file A that contains pairs of strings, one per line: \old1 \new1 \old2 \new2 ..... I would like to iterate over file A, and for each line perform the replacement (e.g. "\old1 -> \new1") ...
2
votes
3answers
252 views

Comparing text files using Bash and AWK

I have two text files, and I want to compare their corresponding values according to their rows and columns. By comparing, I mean to check if the values are equal and echo if the values are the same ...
2
votes
5answers
615 views

Why is the first line comment of .sh file necessary? [duplicate]

I was told that the first line shebang (#!/bin/bash) is necessary in the shell script file, and the file won't run accurately without this line. But I tested some scripts. They work just fine without ...
2
votes
2answers
2k views

/usr/bin/env: zsh -: No such file or directory

I get the error /usr/bin/env: zsh -: No such file or directory ...when I run an executable zsh script that starts with the following shebang line: #!/usr/bin/env zsh - Also, FWIW, replacing - ...
2
votes
2answers
86 views

Scripting to domain allocation to server

I have two text files: file #1: domain.txt cocacola.com airtel.com pepsi.com file #2: servers.txt 192.0.53.42 , 4 # 4 domains already allocated on server 192.0.53.42 192.53.1.2 , 1 # 1 ...
2
votes
1answer
378 views

Script for courier maildir folders on CentOS LAMP environment

I'm looking for resources to help me build a script to do monthly maintenance of maildir folders for a typical CentOS LAMP VPS hosting environment. I would like to run a script that runs from a ...
1
vote
1answer
301 views

How can you run a script triggered by a joystick input?

I'm using a Raspberry Pi running Raspbian to power my arcade cabinet. I want to shut the Pi down using the sudo poweroff command without using the keyboard. I'm thinking the best way would be to ...
1
vote
1answer
520 views

Script Command without Junk Character

I'm Using Unix script command to record everything which is output to the terminal and place it in a log file. but when I see recorded file, it also include Junk Character. So how to record terminal ...
1
vote
2answers
314 views

tail -f equivalent

I am seeing several seconds delay with the tail command. I found the cause for it has something to do with nfs services. I am using arch linux and yet to find out how to disable all these services I ...
0
votes
1answer
52 views

Is it possible triggering a script with a change of amount of files in a directory? [duplicate]

Is it possible to create some kind of directory watcher and trigger a script when the folder is not empty? I have a CentOS machine with jenkins CI on it. i would like to create a job that will move ...
0
votes
1answer
186 views

Bash script installing within multiple directories [closed]

I am attempting to write a bash script that will install rbenv from beginning to end. I am on a Mac for interest sake. But there are some things that are not working mainly i am changing the ...
0
votes
1answer
517 views

Script with root permission [duplicate]

Possible Duplicate: Redirecting stdout to a file you don't have write permission on I am creating a script to change the brightness of my laptop. I discovered that I can do this using ...