|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
script to match name with code?
I need a script that could take in a line from one file and match the line up with codes in the order file.
My first file, called names.txt ,contains: >123456789 >987654321 >15946873 >157987513 The other file, called data,contains: GB_00012.faa GB_6789333.faa GB_100098.faa GB_1237700.faa All the data files contain a line startin with ">" symbol, and contain after that point somwhere the names.txt identifier. Ideally I would love the output to be: >123456789 GB_1237700.faa >line from GB file. I know how to do it manually using grep, but having around 10000 different identifiers and three coupled files together, would take me ages to go through one by one. If this is possible to make in a script, I'd be really thankful for the help! ![]() |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Something like this may get you started: Code:
#!/bin/bash
declare -a data_files=()
while IFS= read -r file; do data_files+=("$file"); done < "data"
while IFS='>' read -r _ code; do
grep -H "$code" "${data_files[@]}"
done < "names.txt" |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| pattern match .com in awk script | shreeprabha | Shell Programming and Scripting | 2 | 05-11-2011 06:58 PM |
| how to convert a shell script to a php script for displaying next word after pattern match | sb245 | Shell Programming and Scripting | 0 | 03-02-2011 01:42 AM |
| exact string match ; search and print match | bash_in_my_head | Shell Programming and Scripting | 8 | 05-22-2010 11:41 PM |
| Need help to grep for a title match and then make some queries after the match | leo.maveriick | Shell Programming and Scripting | 3 | 03-24-2010 03:18 PM |
|
|