0

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
  • 1
    your request lacks a bit of info on what is it you're trying to execute in parallel; mind adding some example to your post? Commented Jan 15, 2013 at 16:21

1 Answer 1

1

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 ]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.