How can i delete a keyword starting with x in unix

I am trying to delete key word starting with x in a unix text file.
example, I am trying to delete the words like xaa,xabxbb,xbd and so on....

my input file is some thing like this

xaaa w 1234 5678
rwsd ravi xw123
xbc3 ohrd

want to delete words xaaa,xw123 and xbc3 from the above file...Please help

try ..

awk 'gsub("x*","")' file

It's not working Ryan...giving syntax error :frowning:

sed 's/\(.*\)\(x[a-z]*[0-9]*\)\(.*\)/\1\3/'  file_name.txt

Panyam, Its working gud..but i need to delete that line untill i find some space.for example i have input

xaa=grpsor29bb4:shelf=1:slot=1:pport=1:channel=1-4-4 aaaa

the output should be just aaaaPlease let me know how should i change the command that you have provided.

i'm not sure i'm using ubuntu.

ryandegreat25@ryandegreat25-desktop:~$ cat scrt
#!/bin/sh
awk 'gsub("x*","")' test 
ryandegreat25@ryandegreat25-desktop:~$ ./scrt
aaa w 1234 5678
rwsd ravi w123
bc3 ohrd
ryandegreat25@ryandegreat25-desktop:~$ 

try

awk 'gsub{"x*",""}' test 

---------- Post updated at 09:57 PM ---------- Previous update was at 09:54 PM ----------

well i'm not sure but maybe

awk '{print $NF}' file

A small change will do the work :

sed 's/\(.*\)\(x[^ ]*\)\(.*\)/\1\3/'

Thanks a lot Panyam..it worked perfect.

sed 's/\(.*\)\(x[^ ]*\)\(.*\)/\1\3/' file_name.txt

so this....

sed 's/x[a-z]*[0-9]*//g'

this code also works but only if the word contain numbers or literals.
Thank you

sed 's/\<x[^ ]*//g'