Issue
I have a file containing a bunch of lines like this blabla-any-characters**,**numbers-and-characters
I would like to keep everything before the first comma and remove everything else.
Any hint how to do this with awk or sed?
Thanks
Solution
You can use sed like this:
sed -i.bak 's/,.*$//' file
,.*$
will match anything after first comma and will replace it by an empty string.
-i.bak
is for inline editing in sed.
Answered By - anubhava Answer Checked By - Gilberto Lyons (WPSolving Admin)