![]() |
|
|
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 |
| Shell script help to eliminate files of todays date | richM | Shell Programming and Scripting | 2 | 04-20-2009 04:40 AM |
| Combine fields and eliminate white space | ski | UNIX for Dummies Questions & Answers | 2 | 07-25-2008 01:03 PM |
| Cannot redirect ouput????? | minifish | Shell Programming and Scripting | 3 | 02-20-2008 12:15 PM |
| Eliminate variable checking in a script | BMetelsky | Shell Programming and Scripting | 8 | 12-04-2007 10:59 AM |
| Red Hat - ouput capture | juxtaman | UNIX for Dummies Questions & Answers | 3 | 04-10-2003 11:31 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
pls see below simulation Code:
$ more file Sun Jan 11 11:20:10 2009 1 0 /home/output/file2311_recent.list user1 user2 0 done Sun Jan 11 11:20:10 2009 1 0 /home/output/file2312 jan recent.list firstname.lastname user2 0 done Sun Jan 11 11:20:10 2009 1 0 /home/output/Output.2313 feb recent.text user1 user2 0 done $ grep -o '/[^.]*[^ ]*' file /home/output/file2311_recent.list /home/output/file2312 jan recent.list /home/output/Output.2313 first two is ok, last is not. because there is "." in file name. whereas going by fields, results should always be consistent Code:
# python -c "for line in open('file'): print ' '.join(line.split()[7:-4])"
/home/output/file2311_recent.list
/home/output/file2312 jan recent.list
/home/output/Output.2313 feb recent.text
Last edited by ghostdog74; 10-22-2009 at 02:48 AM.. |
|
||||
|
All the codes are great, Many Thanks!,
Scrutinizer , thanks for explaining the regular expression, it is crystal clear . Thanks Ghostdog74 for pointing out the extra dot in file name issue(.) The idea with eliminating the left and right fields and keeping the desired one makes it perfect. sed is fine except the extra . , nawk couldnt check, rev & python worked very well, Tx. Rveri. |
![]() |
| Bookmarks |
| Tags |
| scripting, sed awk shell |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|