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)

4
votes
2answers
4k views

How to start VNC server on start-up in Ubuntu 10.04

I've been struggling with this long enough to ask yet another startup script question. I've got a startup script that is relatively simple, ie: ### BEGIN INIT INFO # Provides: startVNC # ...
4
votes
2answers
13k views

Can I fix bad blocks on my hard disk with a single command?

I'm working on fixing the errors in my Hard Disk, It's possible to do that manually but it might take hours. After typing this command sudo badblocks -b 512 /dev/sda, I got hundreds of results and I ...
6
votes
3answers
36k views

How can I know if IP Multicast is enabled

I have scripts that run IP multicast tests; however, my scripts are failing on a particular linux machine. I know that I can look at CONFIG_IP_MULTICAST in the kernel configuration file to determine ...
2
votes
3answers
1k views

How universal is the -L (dereference symlink) switch of the 'ls' command?

I have some software that, among other things, needs to: Assess a file's rwxrwxrwx permissions; Work under every possible flavor of Unix and Linux you can find in the wild. Currently, it does that ...
8
votes
1answer
5k views

How to automatically record all your terminal sessions with script utility

What I want to achieve is be able to record my terminal sessions to file automatically whenever I use Yakuake/Konsole. It's easy to achieve if at the start of my session I do: script -f ...
3
votes
1answer
329 views

Labeling/Aliasing multiple network addresses

If my machine is connected to several networks and configured with multiple addresses (ipv4), is it wise to configure and use labels to identify them ? By labels I mean the iproute2 ip command's ...
3
votes
1answer
1k views

What are my options for integrating audacity into shell scripts?

Just generally, I mean. Ideally I want to be able to script the nyquist plugins directly from the Linux command line by means of one-liners. A cursory glance at scripting audacity shows that it's ...
0
votes
2answers
567 views

getting file name from the input path to the file in shell scripts [duplicate]

Possible Duplicate: Best way to remove file extension from a string? Say that I have a script called script.sh In the shell I type script.sh ../folder/file.py and in that file I know ...
5
votes
4answers
2k views

How to perform a sed in-place substitution that only creates backups of files that were changed?

I ran the following to replace a term used in all files in the current working directory: $ find . -type f -print0 | xargs -0 sed -i'.bup' -e's/Ms. Johnson/Mrs. Melbin/g' This performed the word ...
4
votes
2answers
2k views

How to copy someone's else folders from public.me.com with a wget-like tool?

How can I copy a folder from http://public.me.com/ (a service related to iDisk, or MobileMe) to my local filesystem with a Unix tool (like wget, a command-line non-interactive tool)? The problem is ...
3
votes
1answer
418 views

An efficient filter for .sql files with just “INSERT INTO”

Several times I've found myself working on data that has been exported to .sql files that I want to process rather than import into a database. I'm only talking about "pure data" sql files. Ones that ...
5
votes
2answers
2k views

Privoxy: blocking twitter, facebook and google outside of their domainslr

Related subject: blocking facebook.com outside facebook.com domain This is from default.filter ################################################################################# # # shockwave-flash: ...
12
votes
2answers
9k 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. ...
3
votes
1answer
1k views

How to use a value returned by a script in grep filter?

I'm on FreeBSD's csh. I want to form a row with domains of one user and then use this row to filter exim maillog to get only mail from/to this user's domains. I wrote a script to form a row from a ...
9
votes
3answers
8k 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 ...
2
votes
2answers
389 views

add “check if fetchmail is running” to this script

while ! postqueue -p | grep -q empty; do sleep 1 done killall wvdial this script checks if my mail queue is empty, then disconnects my modem. now i would like to add also a checking to fetchmail ...
1
vote
3answers
706 views

To list out duplicate filenames in a listing?

bash-3.00$ cat f.txt -rw-r--r-- 1 mukesh other 102 Nov 5 18:32 f1.txt -rw-r--r-- 1 mukesh other 19 Nov 5 18:32 f2.txt -rw-r--r-- 1 mukesh other 204 Nov 5 18:32 ...
20
votes
4answers
10k views

How do I exit a script in a conditional statement?

I'm writing a bash script where I want to exit if the user is not root. The conditional works fine, but the script does not exit. [[ `id -u` == 0 ]] || (echo "Must be root to run script"; exit) ...
2
votes
2answers
1k views

Ignoring files that find cannnot search or open?

I searched for big files using this command on HP Unix: find . -type f -size +100000000c -exec ls -lrt {} \; The result came out somthing like this: -rw-rw-rw- 1 qa1wrk32 test 169263642 ...
9
votes
3answers
700 views

How to pipe the list of commands displayed by of “tab complete”?

When using commands in bash I like the double tab option to display the available commands. Some commands have more possible matches than others: Is there a way I can pipe the output of the double ...
0
votes
1answer
493 views

Making a simple PHP script process text in a pipe

Last week I wanted to convert some simplified Chinese characters into traditional ones. I found a deceptively nice looking shell one-liner, which today I found out was 20% error prone. So I did some ...
5
votes
3answers
573 views

What does the syntax on this shell command with extglob mean?

In Building paths robustly, A solution is proposed that includes: shopt -s extglob; dir="${dir//+(\/)//}" Can someone explain (parse) that for me? I understand what it's doing, but not how the ...
1
vote
3answers
354 views

ksh cannot cp from location with space in it?

I am trying to do the following in ksh but keep getting cannot stat message for the cp command: JMX_ROOT=/bfs-build/build-info/mep_mainline-Linux.latest/core/mainline/automation ...
1
vote
1answer
1k views

Concatenate multiple strings with spaces in them?

I am trying to do the following in ksh shell: JMX_ROOT=/bfs-build/build-info/mep_mainline-Linux.latest/core/mainline/automation SMOKE_JMX_LOCATION="$JMX_ROOT/\"Smoke Set\"/*.txt $JMX_ROOT/\"Smoke ...
11
votes
3answers
4k views

How to “send” variable to sub-shell?

I run the following script: VAR="Test" sh -c 'echo "Hello $VAR"' But I get : # ./test.sh Hello How can I "send" the variable VAR of my script to the shell created with sh -c?
2
votes
2answers
4k views

How to exclude a list of full directory paths in find command on Solaris

(Duplicated from Stack Overflow: http://stackoverflow.com/questions/7854975/how-to-exclude-a-list-of-full-directory-paths-in-find-command-on-solaris) I have a very specific need to find unowned files ...
2
votes
1answer
136 views

Start and stop multiple executable for easy debugging

I'm debugging a networking project, which involves interacting of 3 programs, ie a server, two different clients. However I find it difficult to start and stop them for debugging. Some methods I have ...
4
votes
5answers
10k views

Match regex in ksh

I am looking to do something like this in KSH: if (( $var = (foo|bar)[0-9]*$ )); then print "variable matched regex" fi Is it possible at all? For the record I'm using Ksh Version M-11/16/88i ...
1
vote
2answers
162 views

How to log if an environment variable is unset? [closed]

How can I write a shell script that checks for an environment variable and writes to a log file if the variable is unset? Also, if the file name pointed by env variable doesn't exist, how to create ...
1
vote
3answers
433 views

Evalute passed in variable in bash

Is there a way to pass in a variable as an argument to a bash script and have it evaluated scoped by the bash script? Given: # cat /path/to/file/of/host/names bob tom joe etc... # dofor FILE=$1 ...
4
votes
3answers
4k views

How to watch rss feed for new entries from bash script?

I need to watch a RSS feed from our hudson ci server. Each time a new entry is available i want to play a sound by calling #>play sound.wav. Does anyone know a tool which can watch a rss-feed and ...
5
votes
4answers
1k views

Last failed command in bash

The $? variable holds the exit status of last run command. Is there a variable that holds last run command itself?
1
vote
2answers
349 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 ...
9
votes
2answers
2k views

Piping for loop output prevents local variable modification

I'm trying to write a simple bash function that takes, as its arguments, a number of files and/or directories. It should: Fully qualify the filenames. Sort them. Remove duplicates. Print all that ...
6
votes
5answers
971 views

Shell programming, avoiding tempfiles

I often write KSH shell scripts that follow the same pattern: (1) retrieve output from one or more command (2) format it using grep|cut|awk|sed and print it to the screen or to a file In order to ...
4
votes
1answer
411 views

Alternatives to XDialog

Are there any alternatives to XDialog? Ideally something that would support both X server and terminal interface.
1
vote
2answers
914 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 ...
5
votes
1answer
780 views

Automated incremental backups to an external drive

Background A client needs an automated backup solution to an external drive (to be taken offsite weekly). I'd typically suggest rsnapshot (or perhaps rolling out a custom rsync script), but this ...
2
votes
2answers
596 views

Comparing files and their properties

I get information of a certain set of files in my mail every day, which looks like this: 58623208 Sep 14 20:08 blbn_blfbe_drv 57904920 Sep 14 19:54 blbn_cycmn 55814208 Sep 14 06:02 clsa_Upd 38912000 ...
4
votes
1answer
2k views

shorthand for feeding contents of multiple files to the stdin of a script

Hi good people of this community, Say I have a script called script, that reads from stdin and spits out some results to the screen. If I wanted to feed it contents of one file, I would have typed: ...
4
votes
2answers
386 views

Should I be using 'sudo' in scripts that I write?

I'm setting up a new machine (well actually, an Ubuntu VM) and am trying to write a script to setup a few common things that I use when doing this (Git, curl, vim + janus). So my script looks a bit ...
3
votes
3answers
2k views

How can I test if a program is running from within a script

Let's assume that another user started a bunzip process, and I have a script that I'd like to start running after that bunzip finishes. What's the best way to check from inside my script that the ...
3
votes
1answer
2k views

How can I use imagemagick's identify command in a script to tell if a JPEG file is invalid or corrupt?

I have a somewhat-kludgey script in which I want to copy valid, complete JPEG files to a photo album directory. I thought I could use ImageMagick's identify command to do this. The web documentation ...
3
votes
1answer
175 views

Help improving my AWK skills

This program works as I intended but I feel like I used some clumsy methods to get the out put I desired(especially with my use of print commands and variable declarations) Could some one improve ...
2
votes
2answers
88 views

How do I execute a command on a given string in each line of a file?

Let's assume that I already have a file created. This file creation comes from the execution of a command. The contents of the file will be up to 4 different lines looking something like this: LUN ...
13
votes
3answers
1k views

How to make those old-school GUIs (like the debian/arch installer)

I've been doing a lot of installs lately, and when possible I usually opt for the text install from the Live CD's GRUB menu. Most installers looks like this: I always thought these GUIs (if you can ...
3
votes
2answers
75 views

Text files with sections in common with a given file

I need to maintain a set of plain text files saved in a directory which all have a section taken from another file. An example follows: Files: /directory/textfile1 (every other file in the directory ...
2
votes
1answer
612 views

How do I replace certain text with the respective line number using sed?

I have a file where certain (not all) lines look like so: Sequence: n I wish to replace n with the respective line number. How can I do it with sed?
4
votes
2answers
1k views

What does `export COLUMNS` do?

What is the significance of importance of the command export COLUMNS ? What I know is that it's a global variable. I frequently see it in the beginning of *nix scripts.
9
votes
9answers
12k views

Automatically run commands over SSH on many servers

There is a list of IP addresses in a .txt file, ex.: 1.1.1.1 2.2.2.2 3.3.3.3 Behind every IP address there is a server, and on every server there is an sshd running on port 22. Not every server is ...