Hello,
I'm trying to run some commands in paralel, in background, using bash. Here's what I'm trying to do:
forloop {
//this part is actually written in perl
//call command sequence
print `touch .file1.lock; cp bigfile1 /destination; rm .file1.lock;`;
}
The part between backticks (``) spawns a new shell and executes the command...
In the GNOME Terminal, Bash does smart auto-completion. For example
apt-get in<TAB>
becomes
apt-get install
In Emacs shell-mode, this auto-completion doesn't work, even after I explicitly source /etc/bash_completion. The above example sticks as in or auto-completes with a filename in the current directory rather than a valid apt-ge...
Update: Thanks for the suggestions guys. After further research, I’ve reformulated the question here: Python/editline on OS X: £ sign seems to be bound to ed-prev-word
On Mac OS X I can’t enter a pound sterling sign (£) into the Python interactive shell.
Mac OS X 10.5.5
Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
European keyboar...
How do I iterate over a range of numbers in bash when the range is given by a variable?
I know I can do this:
for i in {1..5}; do echo $i; done
Which gives:
1
2
3
4
5
Yet how can I replace either of the range endpoints with a variable? This doesn't work:
END=5
for i in {1..$END}; do echo $i; done
Which prints:
...
I want to prevent my script running more than once at a time.
My current approach is
create a semaphore file containing the pid of the running process
read the file, if my process-id is not in it exit (you never know...)
at the end of the processing, delete the file
In order to prevent the process from hanging, I set up a cron job ...
When you take your first look at an Oracle database, one of the first questions is often "where's the alert log?". Grid Control can tell you, but its often not available in the environment.
I posted some bash and Perl scripts to find and tail the alert log on my blog some time back, and I'm surprised to see that post still getting lots ...
Is it possible to check a bash script syntax without executing it?
Using Perl, I can run perl -c 'script name', is there any equivalent command for bash scripts?
Thanks.
...
I'm looking to call a subprocess with a file descriptor opened to a given pipe such that the open() call does not hang waiting for the other side of the pipe to receive a connection.
To demonstrate:
$ mkfifo /tmp/foobar.pipe
$ some_program --command-fd=5 5</tmp/foobar.pipe
In this case, some_program is not run until some process has ...
Every time I use the "at" command, I get this message:
warning: commands will be executed using /bin/sh
What is it trying to warn me about? More importantly, how do I turn the warning off?
...
Is there a command within the bash shell of fedora that will give me the currently assigned IP address?
...
What's a quick-and-dirty way to make sure that only one instance of a shell script is running at a given time?
...
I many times have to work with directories containing hundreds of thousands of files, doing text matching, replacing and so on. If I go the standard route of, say
grep foo *
I get the too many files error message, so I end up doing
for i in *; do grep foo $i; done
or
find ../path/ | xargs -I{} grep foo "{}"
But these are less th...
There seem to be two bash idioms for redirecting STDOUT and STDERR to a file:
fooscript &> foo
... and ...
fooscript > foo 2>&1
What's the difference? It seems to me that the first one is just a shortcut for the second one, but my coworker contends that the second one will produce no output even if there's an error with the initia...
I have already extracted the tag from the source document using grep but, now I cant seem to figure out how to easily extract the properties from the string. Also I want to avoid having to use any programs that would not usually be present on a standard installation.
$tag='<img src="http://imgs.xkcd.com/comics/barrel_cropped_(1).jpg"...
I've run into a problem where I'm getting two printouts of my /etc/motd file on Gentoo Linux. sshd is doing one of the printouts, and I can toggle that by configuring /etc/ssh/sshd_config, but I can't find out who's printing the second copy. I can't disable sshd from printing out the motd due to an audit requirement. I'm running the b...
Say I have a script that gets called with this line:
./myscript -vfd ./foo/bar/someFile -o /fizz/someOtherFile
or this one:
./myscript -v -f -d -o /fizz/someOtherFile ./foo/bar/someFile
What's the accepted way of parsing this such that in each case (or some combination of the two) $v $f $d will all be set to true and $outFile will ...
The way you would normally include a script is with "source"
eg:
main.sh:
#!/bin/bash
source incl.sh
echo "The main script"
incl.sh:
echo "The included script"
The output of executing "./main.sh" is:
The included script
The main script
... Now, if you attempt to execute that shell script from another location, it can't find ...
How can I determine the name of the bash script file inside the script itself?
Like if my script is in file runme.sh, than how would I make it to display "You are running runme.sh" message without hardcodding that?
Thanks,
...
I am a heavy command line user and use the find command extensively in my build system scripts. However on Mac OS X when I am not concentrating I often get output like this:
$ find -name \*.plist
find: illegal option -- n
find: illegal option -- a
find: illegal option -- m
find: illegal option -- e
find: *.plist: No such file or directo...
Is it possible to copy a single file to multiple directories using the cp command ?
I tried the following , which did not work:
cp file1 /foo/ /bar/
cp file1 {/foo/,/bar}
I know it's possible using a for loop, or find. But is it possible using the gnu cp command?
...