Computing.Net > Forums > Unix > How can i delete a keyword starting with x in

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How can i delete a keyword starting with x in

Reply to Message Icon

Name: rdhanek
Date: July 23, 2009 at 05:15:05 Pacific
OS: sun solaris
Subcategory: General
Comment:

I am trying to delete words starting with x from a text file in unix.
e.g: xaa, xab ...
Please help me



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: July 23, 2009 at 17:06:12 Pacific
Reply:

This awk script looks at each field and if the field starts with x and is composed of characters and numbers, then set to the field to a space:

I am using Solaris nawk.


nawk ' {

for(i=1; i<=NF; i++)
gsub("^x[0-9A-Za-z]*$", "", $i)
print $0

} ' datafile


0

Response Number 2
Name: lankrypt0
Date: July 29, 2009 at 08:20:50 Pacific
Reply:

are the words on their own line or at the beginning of a line, or can they appear anywhere in the file?


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: How can i delete a keyword starting with x in

How can i install a scsitape on solaris 2.7? www.computing.net/answers/unix/how-can-i-install-a-scsitape-on-solaris-27/1671.html

Deleting a file in unix www.computing.net/answers/unix/deleting-a-file-in-unix-/7581.html

can't delete a file www.computing.net/answers/unix/cant-delete-a-file/1755.html