I have a file which has 10-20 records. I need to call a process over these records. Can someone help me write some multithreaded shell script for it?
1 Answer
In a general execution, you may use xargs:
cat file | xargs -n 1 -I {} bash -c 'your_script.sh {}'
Having {} as an argument being given to your_script.sh, and -n 1 determining the number of lines to be passed as arguments to your script.
For example:
$ cat > file
a
b
c
$ cat > t.sh
echo [ $1 ];
$ cat file | xargs -n 1 -I {} bash -c './t.sh {}'
[ a ]
[ b ]
[ c ]