Remove a substring from string

Good morning friends,

how can i remove a string with linux scripting from a file? In specific i want to remove from a file all the tweet names and links
eg
@aerta and links such as http://dst.co/pIiu3i9c

Thanx!!!

sed -e "s?http://[^ ]*??g" -e "s/@aerta//g" file
1 Like

anbu23's proposal is fine, but you may want to replace s/@aerta//g by s/@[^ ]*//g so your script will be more generic.

1 Like

Thanks for the replay it seems to work for the links but the usernames can be anything... not just @aerta

Thanks for your reply!!!

---------- Post updated at 03:01 AM ---------- Previous update was at 02:59 AM ----------

That is exactly what i wanted!!! Thanks, have a nice day!!

A perl:

perl -pe 's/@\S+|http:\/\/\S+//g' infile
1 Like