![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| reading line by line a variable | pppswing | Shell Programming and Scripting | 4 | 07-02-2008 11:51 AM |
| reading ps command's output line by line | s. murat | Shell Programming and Scripting | 5 | 05-22-2008 05:23 AM |
| reading text file line by line | MizzGail | Shell Programming and Scripting | 6 | 04-14-2008 07:58 AM |
| Ksh Storing Multiple Files and reading each line in each file. | developncode | UNIX for Dummies Questions & Answers | 1 | 04-08-2008 05:44 PM |
| reading line by line and grepping | QueryMaster | Shell Programming and Scripting | 4 | 01-30-2008 05:12 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
hi
am having two files more file1 a b c d more file2 a b c d i need a loop to read the 1st line from file1 and 1st line from file 2 and grep them from file3. Then go read the 2nd line and go on... i tried to do it but it was a mess. |
|
||||
|
I am assuming 'grep from file 3' means grep -f file3, not read a record from file three to grep file 1 and file 2 records. Code:
paste file1.txt file2.txt | grep -f file3.txt or the other way 'round: grep single file3 record against rec1 and rec2 Code:
cnt=$( wc -l file1.txt)
> dummy1
while [[ $cnt -gt 0 ]]
do
echo '|' >> dummy1
cnt=$(( cnt - 1))
done
cp dummy1 dummy2
paste file1.txt dummy1 file2.txt dummy2 file3.txt | \
while IFS='|' && read rec1 rec2 rec3
do
echo "$rec1"| grep "$rec3"
echo "$rec2" | grep "$rec3"
done
|
|
||||
|
Thank you jim mcnamara
it worked "somehow", but now i ve a nother problem ive input file contains to clums a and b spreated by pipe a | b 123|456 323|455 and xyz contains other info about a and b now i want to print as follows: a | b | "info from xyz" but "info from xyz" might be more than 1 line and i want to keep the format to 3 cloums. how to do it? i tried the belw script but printing was worng. Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|