![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| Grep commands in loop | karthikn7974 | Shell Programming and Scripting | 0 | 04-28-2008 09:16 AM |
| grep and awk showing filename in loop | sjohns6 | Shell Programming and Scripting | 5 | 05-24-2007 08:59 AM |
| grep -v while loop | bobo | UNIX for Dummies Questions & Answers | 8 | 01-26-2007 10:53 PM |
| grep in a loop | gundu | Shell Programming and Scripting | 7 | 03-28-2005 04:59 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
||||
|
Hi ,
1. I want to grep two or three lines from a set of files and put the grepped lines into again a set of files.like file1-greppedfile1 file2-greppedfile2 then again do some format to the grepped files with sed or awk then create another set of files. How can I do this in loop? 2.I want to grep a date within a file.The date is at almost end of the file but there are also some dates above the last date format which i have to grep. Help will be appreciated... Thanks |
|
||||
|
Your second problem looks like you want to get from a file the last line containing a date. If so, then try something like
Code:
grep date file | tail -n 1 |
|
||||
|
I did it for one file
Hi,
I am beginner in shell scripting.I have done the grep for one file like grep -i 'abcd' from file1>file2 grep '1234' from file1>>file2 then by awk I have divided '1234/234' and appended file2>file3. This I have to do it for 5 files. for each file there must be seperate result file.I can do it manually but this is to be run like a job. I hope you got my my problem.. |
|
||||
|
Alrighty, this might not be the most efficient way of doing this, but you can give this a try..
suppose you have file1, file2,file3,file4 and so on to grep, Code:
arg1=abcd arg2=1234 for i in file* do grep -i $arg1 $i >$arg1_$i grep -j $arg2 $i >$arg2_$i done find . -empty | xargs rm |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|