I have a file like this.
rm a.txt
mkdir foo
cp a.doc docs
I am used to xargs but following command is not doing anything.
cat commands.txt | xargs -l1
I have a file like this.
rm a.txt
mkdir foo
cp a.doc docs
I am used to xargs but following command is not doing anything.
cat commands.txt | xargs -l1
Erm :
$ mv commands.txt commands.sh
$ chmod +x command.sh
$ ./command.sh
you are doing it wrong! if your file is all shell commands, treat it as a shell script.
#!/bin/bash
rm a.txt
mkdir foo
cp a.doc docs
then on command line , chmod u+x commands.txt
./commands.txt
the "defacto" naming convention for shell script ends with extension .sh, although it can be anything. So try to name your script as ".sh" extension
If you don't need to make it executable, source it in your current shell:
bash/ksh/...: . commands.txt
csh/...: source commands.txt
If you commands are not in a file but the output from a program you may do use GNU Parallel http://www.gnu.org/software/parallel/:
cat commands.txt | parallel -j1
If the commands can be run in parallel (i.e. do not depend on eachother to complete) you can even do:
cat commands.txt | parallel