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
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.
Try this with cut:
cut -d ',' -f 1 file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With