Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i awk the file name only? 2

Status
Not open for further replies.

farley99

MIS
Feb 12, 2003
413
US
How do i awk the file name only?
1AADtP-0003FR-MF-D:imap failed @ Thu Oct 16 14:34:39 2003. A restart was attempted automagicly.
1AADUP-00038A-Eh-D:imap failed @ Thu Oct 16 14:08:49 2003. A restart was attempted automagicly.
1AAE1k-0003Hs-Dy-D:imap failed @ Thu Oct 16 14:43:16 2003. A restart was attempted automagicly.
1AAEA5-0003KG-6u-D:imap failed @ Thu Oct 16 14:51:53 2003. A restart was attempted automagicly.
1AAEIP-0003Mm-TT-D:imap failed @ Thu Oct 16 15:00:29 2003. A restart was attempted automagicly.
1AAEQk-0003QI-Mj-D:imap failed @ Thu Oct 16 15:09:06 2003. A restart was attempted automagicly.
1AAEZ5-0006Ns-G1-D:imap failed @ Thu Oct 16 15:17:43 2003. A restart was attempted automagicly.

for i in `grep restart *` ; do rm -rf awk((^.*):?,$i) ; done

What is the correct syntax to awk the file name only 1AAEZ5-0006Ns-G1-D ?
 
This not tested but might be close.

awk '/restart/{sub(/:*/,"");system("rm -rf " $0)}' *

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
Sorry, minor typo

awk '/restart/{sub(/:[red].[/red]*/,"");system("rm -rf " $0)}' *

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
Farley99,

What about something simple like the example below?

grep restart filename | awk -F: '{print $1}'

Thanks,

John
 
Or even simpler:

awk -F: '/restart/{print $1}' filename

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top