to print output using shell command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting to print output using shell command
# 8  
Old 07-30-2007
dear shell_life
when i use ur code
Code:
csplit -f file1 input_file /^>/ {99}
for mFile in `egrep -l -f reference_file file2`
do
 cat ${mFile}
done

it shows display
Code:
shell_life.sh: line 1: /: Is a directory
cat: invalid option -- l
Try `cat --help' for more information.

Thanks
# 9  
Old 07-30-2007
Cdfd,
Please, run exactly my code below:
Code:
csplit -k -f xyz input_file '/^>/' {99} 1,2>/dev/null
for mFile in `egrep -l -f reference_file xyz*`
do
  cat ${mFile}
done

Where:
xyz: Is a prefix to be used to generate split files.
input_file: Your large file.
reference_file: Your reference file with patterns.

Last edited by Shell_Life; 07-30-2007 at 04:09 PM.. Reason: Add single quotes, '-k' and /dev/null.
# 10  
Old 08-02-2007
Dear shell_life,
i have exactly follows urs code tht is
csplit -k -f xyz file1 '/^>/' {99} 1,2>/dev/null
for mFile in 'egrep -l -f file3 xyz*'
do
cat ${mFile}
done

where file1
Code:
>O94911|ABCA8_HUMAN ATP-binding cassette sub-family A member 8 - Homo sapiens (Human)
MRKRKISVCQQTWALLCKNFLKKWRMKRESLMEWLNSLLLLLCLYIYPHSHQVNDFSSLL
TMDLGRVDTFNESRFSVVYTPVTNTTQQIMNKVASTPFLAGKEVLGLPDEESIKEFTANY
PEEIVRVTFTNTYSYHLKFLLGHGMPAKKEHKDHTAHCYETNEDVYCEVSVFWKEGFVAL
QAAINAAIIEITTNHSVMEELMSVTGKNMKMHSFIGQSGVITDLYLFSCIISFSSFIYYA
>gi|114670186|ref|XP_001165971.1| PREDICTED: similar to KIAA0822 protein isoform 5 [Pan troglodytes]
MRKRKISVCQQTWALLCKNFLKKWRMKRESLMEWLNSLLLLLCLYIYPHSHQVNDFSSLLTMDLGRVDTFNESRFSVVYT
PVTNTTQQIMNKVASIPFLAGKEVLGLPDEESIKEFTANYPEEIVRVTFTNTYSYHLKFLLGHGMPAKKEHKDHTAHCYE
TNEDVYCEVSVFWKEGFVALQAAINAAIIEITTNHSVMEELMSVTGKNMKMHSFIGQSGVITDLYLFSCLISFSSFIYYA
>gi|109117480|ref|XP_001082492.1| PREDICTED: similar to ATP-binding cassette, sub-family A member 8 isoform 2 [Macaca mulatta]
MRKREISVCQQTWALLCKNFLKKWRMKRESLMEWLNSFLLLLCLYIYPHSHQVNDFSSLLTTDLGRVDTFNESRFSVAYT
PVTNTTQQIMNKVASAPFLAGKEVLGLPDEESIKEFTANYPEEIVRVIFTNTYSYQLKFLLGHEMPAKKEHKDHTAHCYE
TNEDVYCEVSVFWKEGFVALQAAINAAIIEITTNHSVMEELMSVTGKNMKMHSFIGQSGVITDLYLFSCIISFSPFIYYA
SVNVTRERKRMKGLMTMMGLRDSAFWLSWGLLYAGFIFIMALFLALVIKSTLFIILSGFMVVFSLFLLYGLSLIALAFLM
SILVKKSFLTGLVVFLLTVFWGSLGFTALYRYLPASLEWILSLLSPFAFMLGMAQLLHLDYDLNSNAFPHPLDGSNIIVA
TNFMLAFDTCLYLALAIYFEKILPNEYGHRRSPLFFLKSSFWSQTQKADHVALEDEMDADPSSHDSFEPVPPEFHGKEAI
RIRN
>gi|114670192|ref|XP_001165871.1| PREDICTED: similar to KIAA0822 protein isoform 2 [Pan troglodytes]
MNHTSRFLASIFPEEWLNSLLLLLCLYIYPHSHQVNDFSSLLTMDLGRVDTFNESRFSVVYTPVTNTTQQIMNKVASIPF
LAGKEVLGLPDEESIKEFTANYPEEIVRVTFTNTYSYHLKFLLGHGMPAKKEHKDHTAHCYETNEDVYCEVSVFWKEGFV
ALQAAINAAIIEITTNHSVMEELMSVTGKNMKMHSFIGQSGVITDLYLFSCLISFSSFIYYASVNVTRERKRMKGLMTMM
GLRDSAFWLSWGLLYAGFIFIMALFLALVIKSTQFIILSGFMVVFSLFLLYGLSLVALAFLMSILVKKSFLTGLVVFLLT
VTKEYKGKPDKIEALKDLVFDIYEGQITAILGHSGAGKSTLLNILSGLSTPTKGSVTIYNNKLSEVADLENLSKLT


And File 3 is
>ref|XP_001165971.1| PREDICTED: similar to KIAA0822 protein isoform 5 [Pan troglodytes]
>ref|XP_001082492.1| PREDICTED: similar to ATP-binding cassette, sub-family A member 8[Macaca mulatta]
>ref|XP_001165871.1| PREDICTED: similar to KIAA0822 protein isoform 2 [Pan troglodytes]
>ref|XP_001494133.1| PREDICTED: similar to ABCA8 protein [Equus caballus]

While running this code this shows the error 
csplit: 1,2: invalid pattern
Try `cat --help' for more information.

My output is just like searching for file3 in file1 
shoulld give that 
>ref|XP_001165971.1| PREDICTED: similar to KIAA0822 protein isoform 5 [Pan troglodytes]
MRKRKISVCQQTWALLCKNFLKKWRMKRESLMEWLNSLLLLLCLYIYPHSHQVNDFSSLLTMDLGRVDTFNESRFSVVYT
PVTNTTQQIMNKVASIPFLAGKEVLGLPDEESIKEFTANYPEEIVRVTFTNTYSYHLKFLLGHGMPAKKEHKDHTAHCYE
TNEDVYCEVSVFWKEGFVALQAAINAAIIEITTNHSVMEELMSVTGKNMKMHSFIGQSGVITDLYLFSCLISFSSFIYYA

contiuning those which are in file3 with single ine

One question wht prefix u have written xyz is not understood to me .
if possible
Thanks

Last edited by cdfd123; 08-02-2007 at 03:46 AM..
# 11  
Old 08-02-2007
Power

Quote:
Originally Posted by matrixmadhan
As per the example you had provided,

this is file 1

Code:
1.>ref|XP_001165971.1| PREDICTED: similar to KIAA0822 protein isoform 5 [Pan troglodytes]
2.>ref|XP_001494133.1| PREDICTED: similar to ABCA8 protein [Equus caballus]
3. >ref|XP_001082492.1| PREDICTED: similar to ATP-binding cassette, sub-family A member 8[Macaca mulatta]

and the other big file is file 2


Please use CODE tags Smilie


Dear matrixpradhan,
i have exactly follow the same code
still it give no output means blank results .....
thanks u......
i have written question again as u can see in this part
regards
cdfd123
# 12  
Old 08-02-2007
Quote:
Originally Posted by Shell_Life
Cdfd,
Please, run exactly my code below:
Code:
csplit -k -f xyz input_file '/^>/' {99} 1,2>/dev/null
for mFile in `egrep -l -f reference_file xyz*`
do
  cat ${mFile}
done

Where:
xyz: Is a prefix to be used to generate split files.
input_file: Your large file.
reference_file: Your reference file with patterns.

Dear shell_life,
i have exactly follows urs code tht is
csplit -k -f xyz file1 '/^>/' {99} 1,2>/dev/null
for mFile in 'egrep -l -f file3 xyz*'
do
cat ${mFile}
done

where file1
Code:
>O94911|ABCA8_HUMAN ATP-binding cassette sub-family A member 8 - Homo sapiens (Human)
MRKRKISVCQQTWALLCKNFLKKWRMKRESLMEWLNSLLLLLCLYIYPHSHQVNDFSSLL
TMDLGRVDTFNESRFSVVYTPVTNTTQQIMNKVASTPFLAGKEVLGLPDEESIKEFTANY
PEEIVRVTFTNTYSYHLKFLLGHGMPAKKEHKDHTAHCYETNEDVYCEVSVFWKEGFVAL
QAAINAAIIEITTNHSVMEELMSVTGKNMKMHSFIGQSGVITDLYLFSCIISFSSFIYYA
>gi|114670186|ref|XP_001165971.1| PREDICTED: similar to KIAA0822 protein isoform 5 [Pan troglodytes]
MRKRKISVCQQTWALLCKNFLKKWRMKRESLMEWLNSLLLLLCLYIYPHSHQVNDFSSLLTMDLGRVDTFNESRFSVVYT
PVTNTTQQIMNKVASIPFLAGKEVLGLPDEESIKEFTANYPEEIVRVTFTNTYSYHLKFLLGHGMPAKKEHKDHTAHCYE
TNEDVYCEVSVFWKEGFVALQAAINAAIIEITTNHSVMEELMSVTGKNMKMHSFIGQSGVITDLYLFSCLISFSSFIYYA
>gi|109117480|ref|XP_001082492.1| PREDICTED: similar to ATP-binding cassette, sub-family A member 8 isoform 2 [Macaca mulatta]
MRKREISVCQQTWALLCKNFLKKWRMKRESLMEWLNSFLLLLCLYIYPHSHQVNDFSSLLTTDLGRVDTFNESRFSVAYT
PVTNTTQQIMNKVASAPFLAGKEVLGLPDEESIKEFTANYPEEIVRVIFTNTYSYQLKFLLGHEMPAKKEHKDHTAHCYE
TNEDVYCEVSVFWKEGFVALQAAINAAIIEITTNHSVMEELMSVTGKNMKMHSFIGQSGVITDLYLFSCIISFSPFIYYA
SVNVTRERKRMKGLMTMMGLRDSAFWLSWGLLYAGFIFIMALFLALVIKSTLFIILSGFMVVFSLFLLYGLSLIALAFLM
SILVKKSFLTGLVVFLLTVFWGSLGFTALYRYLPASLEWILSLLSPFAFMLGMAQLLHLDYDLNSNAFPHPLDGSNIIVA
TNFMLAFDTCLYLALAIYFEKILPNEYGHRRSPLFFLKSSFWSQTQKADHVALEDEMDADPSSHDSFEPVPPEFHGKEAI
RIRN
>gi|114670192|ref|XP_001165871.1| PREDICTED: similar to KIAA0822 protein isoform 2 [Pan troglodytes]
MNHTSRFLASIFPEEWLNSLLLLLCLYIYPHSHQVNDFSSLLTMDLGRVDTFNESRFSVVYTPVTNTTQQIMNKVASIPF
LAGKEVLGLPDEESIKEFTANYPEEIVRVTFTNTYSYHLKFLLGHGMPAKKEHKDHTAHCYETNEDVYCEVSVFWKEGFV
ALQAAINAAIIEITTNHSVMEELMSVTGKNMKMHSFIGQSGVITDLYLFSCLISFSSFIYYASVNVTRERKRMKGLMTMM
GLRDSAFWLSWGLLYAGFIFIMALFLALVIKSTQFIILSGFMVVFSLFLLYGLSLVALAFLMSILVKKSFLTGLVVFLLT
VTKEYKGKPDKIEALKDLVFDIYEGQITAILGHSGAGKSTLLNILSGLSTPTKGSVTIYNNKLSEVADLENLSKLT


And File 3 is
>ref|XP_001165971.1| PREDICTED: similar to KIAA0822 protein isoform 5 [Pan troglodytes]
>ref|XP_001082492.1| PREDICTED: similar to ATP-binding cassette, sub-family A member 8[Macaca mulatta]
>ref|XP_001165871.1| PREDICTED: similar to KIAA0822 protein isoform 2 [Pan troglodytes]
>ref|XP_001494133.1| PREDICTED: similar to ABCA8 protein [Equus caballus]

While running this code this shows the error
csplit: 1,2: invalid pattern
Try `cat --help' for more information.

My output is just like searching for file3 in file1
shoulld give that
>ref|XP_001165971.1| PREDICTED: similar to KIAA0822 protein isoform 5 [Pan troglodytes]
MRKRKISVCQQTWALLCKNFLKKWRMKRESLMEWLNSLLLLLCLYIYPHSHQVNDFSSLLTMDLGRVDTFNESRFSVVYT
PVTNTTQQIMNKVASIPFLAGKEVLGLPDEESIKEFTANYPEEIVRVTFTNTYSYHLKFLLGHGMPAKKEHKDHTAHCYE
TNEDVYCEVSVFWKEGFVALQAAINAAIIEITTNHSVMEELMSVTGKNMKMHSFIGQSGVITDLYLFSCLISFSSFIYYA

contiuning those which are in file3 with single ine

One question wht prefix u have written xyz is not understood to me .
if possibleSmilieSmilieSmilie
Thanks
# 13  
Old 08-02-2007
Cdfd,
Please, try the following version -- my bad with '1,2':
Code:
csplit -k -f xyz file1 '/^>/' {99} 1>/dev/null 2>&1
for mFile in `egrep -l -f file3 xyz*`
do
  cat ${mFile}
done

# 14  
Old 08-02-2007
Tools

Quote:
Originally Posted by Shell_Life
Cdfd,
Please, try the following version -- my bad with '1,2':
Code:
csplit -k -f xyz file1 '/^>/' {99} 1>/dev/null 2>&1
for mFile in `egrep -l -f file3 xyz*`
do
  cat ${mFile}
done

Thanks tht code works
it runs like a zoooom....
aha.....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need shell script to Telnet multiple node , Ping some IP and print output

Hi Team, Need shell script to Telnet multiple node , Ping some IP and print output like pass or fail. Need this script to check reachability of multiple nodes at same time. Help me. I use this but not working... Eg. in this script i need to telnet... (4 Replies)
Discussion started by: Ganesh Mankar
4 Replies

2. Shell Programming and Scripting

Need to Print output in table using shell script

#! /bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( ... (4 Replies)
Discussion started by: ankit.mca.aaidu
4 Replies

3. Shell Programming and Scripting

How to print the output of a select query using shell script?

HI, I want to connect to database and fetch the count from a table. The sql query is as below : select count(*) from table_test where test_column='read'; How can I print the output of this statement using shell script. Thanks in advance. (4 Replies)
Discussion started by: confused_info
4 Replies

4. UNIX for Dummies Questions & Answers

Print each output of loop in new column using awk or shell

I have this output from a loop a11 1,2 3,4 5,6 7,8 12,8 5,4 3,6 a12 10,11 12,13 15,18 20,22 a13 ... (3 Replies)
Discussion started by: maryre89
3 Replies

5. AIX

Print output of grep command in multuple lines

HI All, I am using grep command to serach a pattern in a list of files and storing the output in a variable. Then i am applying some logic on that variable to get the required output. But Thing is that when the pattern is present mutiple times in a file, i am getting the output of grep in a... (3 Replies)
Discussion started by: goutam sahoo
3 Replies

6. Shell Programming and Scripting

print output of a command in same as shell in mail : please help

i have written a simple script to print the out of a command and send an mail but i am not getting a shell output here .please see my script present output is like this i need an output as same as shell Postfix log summaries for Jan 24 Grand Totals ------------ messages 1432 received 1439... (2 Replies)
Discussion started by: unimaxlin
2 Replies

7. Shell Programming and Scripting

awk command : To print the output to a file

half of the problem is already solved with the help of bartus11 suggestion I have a txt file having rows and coulmns, i want to perform some operation on a specific coulmn starting from a specific line. 50.000000 1 1 1 1000.00000 1000.00000 ... (5 Replies)
Discussion started by: shashi792
5 Replies

8. Shell Programming and Scripting

how can i print the output of the shell script in bigger size

how can i print the output of the shell script in bigger size eg: echo " hello world" i want to print this in the output with bigger size in the middle of the screen. can someone please help me out in that (2 Replies)
Discussion started by: mail2sant
2 Replies

9. Shell Programming and Scripting

Shell script to search through numbers and print the output

Suppose u have a file like 1 30 ABCSAAHSNJQJALBALMKAANKAMLAMALK 4562676268836826826868268468368282972982 2863923792102370179372012792701739729291 31 60... (8 Replies)
Discussion started by: cdfd123
8 Replies

10. Shell Programming and Scripting

Can we use 'tr' command to print 5th column of output of 'ls -l'

Hi All, I know awk command can do it, but can we use tr command to print 5th column of out put 'ls -l' command???? Regards, Nidhi... (4 Replies)
Discussion started by: Nidhi2177
4 Replies
Login or Register to Ask a Question