cut first 10 lines of file master.txt and paste in ab1.txt and so on
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
cut first 10 lines of file master.txt and paste in ab1.txt and so on
Hello,
I have a file called master.txt containing 1000 lines.
I want to cut first 10 lines of master.txt and paste in data1.txt then submit a job using command "bsub -K -qio ./run1.txt", when this job is finished,
cut first 10 lines of master.txt and paste (replace) in data1.txt (lines should be overwritten, i mean old 10 lines of data1.txt should be deleted and new lines should be paste) and submit "bsub -K -qio ./run1.txt" and so on.
run1.txt contains a single command "./mod.sh data1.txt . >& zlog1.txt"
Total there should be 100 iterations as there are 1000 lines in master.txt
Does LSF support array jobs? In GridEngine aka SGE I would submit one array job running 100 instances and depending on the index $SGE_TASK_ID you get for each job it could honor the relevant lines of the master.txt file. The problem I see with your solution is, that you would need either 100 different data1.txt files, or to wait with the next job until the predecessor finished (to avoid overwriting of the previous data1.txt file).
Aha, LSF has the variable LSB_JOBINDEX, so:
Code:
#!/bin/sh
let START=($LSB_JOBINDEX-1)*100+1
echo "I will handle lines from $START on."
sed -n $START,+99p master.txt > $TMPDIR/input.txt
./mod.sh $TMPDIR/input.txt
and submit with bsub -J "data[1-100]" script.sh (I have no access to LSF, but I think you get the idea). The $TMPDIR should be created by LSF unique to each job.
#!/bin/sh
i=o
while [$i -lt 400]
do
i = [i + 1]
head -10 master.txt > data1.txt | sed -i '1,10d' master.txt ## To cut first 10 lines from master and paste to data1.txt
###bsub -K -qio ./run1.txt ## I used to submit the jobs like this, but there will be 1000 jobs for 10000 lines.
./mod.sh data1.txt . >& zlog1.txt ## this is the only line of file run1.txt. every time, data1.txt should get first 10 lines from master
###rm downdata2.txt
done
any help to correct this code? because, when I checked the data1.txt stays empty.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.