how to submit several commands together


 
Thread Tools Search this Thread
# 1  
how to submit several commands together

Dear all,

I have a simple question. I have many cut commands like below to run. I am wondering how to just type and submit all the commands at once and then each of the command will be run automaticaly one by one. Thanks a lot!

Code:
cut -d ' ' -f  3-2002          chr20_step2.mlprob>chr20_part1.mlprob   
cut -d ' ' -f  2003-4002  chr20_step2.mlprob>chr20_part2.mlprob  
cut -d ' ' -f  4003-6002  chr20_step2.mlprob>chr20_part3.mlprob   
cut -d ' ' -f  6003-8002  chr20_step2.mlprob>chr20_part4.mlprob   
cut -d ' ' -f  8003-10002  chr20_step2.mlprob>chr20_part5.mlprob   
cut -d ' ' -f  10003-12002  chr20_step2.mlprob>chr20_part6.mlprob   
cut -d ' ' -f  12003-14002  chr20_step2.mlprob>chr20_part7.mlprob   
cut -d ' ' -f  14003-16002  chr20_step2.mlprob>chr20_part8.mlprob   
cut -d ' ' -f  16003-18002  chr20_step2.mlprob>chr20_part9.mlprob   
cut -d ' ' -f  18003-20002  chr20_step2.mlprob>chr20_part10.mlprob   
cut -d ' ' -f  20003-22002  chr20_step2.mlprob>chr20_part11.mlprob   
cut -d ' ' -f  22003-24002  chr20_step2.mlprob>chr20_part12.mlprob   
cut -d ' ' -f  24003-26002  chr20_step2.mlprob>chr20_part13.mlprob   
cut -d ' ' -f  26003-28002  chr20_step2.mlprob>chr20_part14.mlprob   
cut -d ' ' -f  28003-30002  chr20_step2.mlprob>chr20_part15.mlprob   
cut -d ' ' -f  30003-32002  chr20_step2.mlprob>chr20_part16.mlprob   
cut -d ' ' -f  32003-34002  chr20_step2.mlprob>chr20_part17.mlprob   
cut -d ' ' -f  34003-36002  chr20_step2.mlprob>chr20_part18.mlprob   
cut -d ' ' -f  36003-38002  chr20_step2.mlprob>chr20_part19.mlprob   
cut -d ' ' -f  38003-40002  chr20_step2.mlprob>chr20_part20.mlprob   
cut -d ' ' -f  40003-42002  chr20_step2.mlprob>chr20_part21.mlprob   
cut -d ' ' -f  42003-44002  chr20_step2.mlprob>chr20_part22.mlprob   
cut -d ' ' -f  44003-46002  chr20_step2.mlprob>chr20_part23.mlprob   
cut -d ' ' -f  46003-48002  chr20_step2.mlprob>chr20_part24.mlprob   
cut -d ' ' -f  48003-50002  chr20_step2.mlprob>chr20_part25.mlprob   
cut -d ' ' -f  50003-52002  chr20_step2.mlprob>chr20_part26.mlprob   
cut -d ' ' -f  52003-54002  chr20_step2.mlprob>chr20_part27.mlprob   
cut -d ' ' -f  54003-56002  chr20_step2.mlprob>chr20_part28.mlprob   
cut -d ' ' -f  56003-58002  chr20_step2.mlprob>chr20_part29.mlprob   
cut -d ' ' -f  58003-60002  chr20_step2.mlprob>chr20_part30.mlprob   
cut -d ' ' -f  60003-62002  chr20_step2.mlprob>chr20_part31.mlprob   
cut -d ' ' -f  62003-64002  chr20_step2.mlprob>chr20_part32.mlprob   
cut -d ' ' -f  64003-66002  chr20_step2.mlprob>chr20_part33.mlprob   
cut -d ' ' -f  66003-68002  chr20_step2.mlprob>chr20_part34.mlprob   
cut -d ' ' -f  68003-70002  chr20_step2.mlprob>chr20_part35.mlprob   
cut -d ' ' -f  70003-72002  chr20_step2.mlprob>chr20_part36.mlprob   
cut -d ' ' -f  72003-72518  chr20_step2.mlprob>chr20_part37.mlprob


Last edited by methyl; 04-02-2012 at 08:46 PM.. Reason: please use code tags
# 2  
copy all the commands in a .sh file and execute the sh file

OR

Just at the end of each command put ; and paste the entire text on terminal
# 3  
I am very surprised that these commands work. It is the highest value I have ever seen in a "-f" parameter (but some considerable margin).
What Operating System and version are you running? What Shell do you use?

What size is the file chr20_step2.mlprob?

You can get the commands to execute concurrently within a modern Bourne-type Shell script by suffixing the command with an ampersand & subject to any kernel limitations on the number of processes for an individual user.

Code:
cut -d ' ' -f  3-2002 chr20_step2.mlprob>chr20_part1.mlprob &


Hmm. This looks like an attempt to break a non-unix text file into 2000 character chunks, with some characters left over at the end of this extremely long record. Have you considered using the unix command split or dd after dealing with the two-character header?

What are you trying to do?

Last edited by methyl; 04-02-2012 at 09:04 PM..
# 4  
Indeed, you could do:

Code:
#!/bin/sh

# Create a file of 3+(2000 * 100) bytes
dd bs=3 count=1 if=/dev/zero > bigfile
dd bs=2000 count=100 if=/dev/zero >> bigfile

exec 5<bigfile

dd bs=3 count=1 of=/dev/null <&5
N=1

dd bs=2000 count=1 of=file$N <&5

while [ -s "file$N" ]
do
  N=`expr $N + 1`
  dd bs=2000 count=1 of=file$N <&5
done

rm file$N

exec 5<&-

# 5  
If it works it works.. Try:
Code:
i=0 ; while [ $((i+=1)) -le 37 ] ; do cut -d ' ' -f $(((i-1)*2000+3))-$((i*2000+2)) chr20_step2.mlprob > chr20_part$i.m1prob; done

Providing there are no more than 72518 columns, otherwise you need to loop until 36 and print the last line separately..
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #523
Difficulty: Medium
Some programming languages implement strings by defining arrays of characters.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SGE submit script

Hi, I'm trying to edit my working bash script to an SGE script in order to submit it as a job to the cluster. Currently I have: #!/bin/bash # Perform fastqc on files in a specified directory. for ((j=1; j <=17; j++)) do directory=/data4/una/batch"$j"/ ... (0 Replies)
Discussion started by: una1992
0 Replies

2. Shell Programming and Scripting

Can't submit a form.

hello my script is submitting POST-data to a site (its not my first script, i've done these before many times (include parsing scripts) but this one is tough) so the problem is i'm submitting a form with firefox and in firebug i see WHAT exactly i'm submitting then when i do EXACTLY the... (28 Replies)
Discussion started by: tip78
28 Replies

3. Post Here to Contact Site Administrators and Moderators

Where to submit my scripts

have a doubt. Where I can submit shell scripts done by me ? (5 Replies)
Discussion started by: linuxadmin
5 Replies

4. Ubuntu

Submit using curl

I'm trying to upload a file to a page using curl and after uploading that file i want to store the redirecting page so i can download the results. I'm using the command: curl "http://apps.gdgps.net/kag_upload.php?kag_type=static&kag_frequency=dual&kag_latency=accurate&... (8 Replies)
Discussion started by: limadario
8 Replies

5. News, Links, Events and Announcements

where to submit my work?

Hello sir, I worked out some features using java,shell programming and modified the bash shell. We have come up with 13 new features. I want to know where should I submit my work so that it would be of some use to the open source professionals :confused: (1 Reply)
Discussion started by: nsharath
1 Replies

6. Shell Programming and Scripting

PHP Help with Form Submit

Hi, I have a custom HTML form that has a couple radio buttons and a text field that requires a number. I'm not a php programmer and could use some help with putting together php code to calculate a total based on the radio button selection and the text field number. ... (3 Replies)
Discussion started by: nck
3 Replies

7. Forum Support Area for Unregistered Users & Account Problems

cant submit anything

hello admins, i dont use unix.com very often - but when i do have questions, i submit them at the site - but now I cannot submit anything in any forum on the site. The is the only forum i could add a new thread. its tells me that my account could be de-righted, or that im tring to submit... (1 Reply)
Discussion started by: congo
1 Replies

8. Shell Programming and Scripting

Cannot submit a background job

Hi all, I am currently facing a problem when i am submitting a script to run in the background to collect statistics round the clock on an AIX box. I don't have root authority nor can I set it in cron. So when i submit the job, it runs fine, but won't let me signoff. It prompts me that... (2 Replies)
Discussion started by: tansha
2 Replies

9. Shell Programming and Scripting

How to submit cron jobs?

How can I write a script to submit a perl script as a cron job but only have it execute once? After it has executed once, I would like it to automatically insert itself again into cron. I want to avoid the situation where I schedule a cron job to run once a day, but end up with multiple... (4 Replies)
Discussion started by: siegfried
4 Replies

Featured Tech Videos