Re: Scripting Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>I need some help and thought someone on this list might know.  I am trying
>to do some scripting but am running into the following problem:
>
>I have a file that contains a bunch of the following entries:
>
>trusty.F.0038 02/11/02
>trusty.F.0058 04/11/04
>trusty.F.0063 05/12/02
>trusty.F.0064 05/13/02
>trusty.F.0178 04/21/04
>trusty.F.0183 09/30/02
>trusty.F.0276 04/04/04
>.....
>
>I would like to take out entries that match 04/xx/04 (xx does not matter)
>and dump them to a different file.  In this case 58, 178 and 276.  I am
>unable to do this with awk.  Anyone know of a way I can do this using
>csh??

An extremely simple two line command line is:

	grep 04/../04 filename > file_with_04
	grep -v 04/../04 filename > file_without_04

Awk can be used a well.  You just use an if statement that looks for the
string "04/" AND the string "/04" in field $2.  If both are found output
$0 into the with file, else output the line into the without file.

Rather simple, really.

MB
-- 
e-mail: vidiot@xxxxxxxxxx                                /~\ The ASCII
                                                         \ / Ribbon Campaign
[So it's true, scythe matters.  Willow  5/12/03]          X  Against
Visit - URL: http://vidiot.com/                          / \ HTML Email


-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux