On 12Feb2017 20:06, bruce <badouglas@xxxxxxxxx> wrote:
Got a quick sed question now..
test file::
head -2 sed.dat
228d98f0_f16a_11e6_9544_1ad613f05f7b,1486934882
22b93712_f16a_11e6_a6ad_1ad613f05f7b,1486934883
I always say "sed 2q" instead of "head -2", myself.
want to simply truncate/search/replace the end of each line starting
with the ","
to get
228d98f0_f16a_11e6_9544_1ad613f05f7b
22b93712_f16a_11e6_a6ad_1ad613f05f7b
the following isn't working
sed -i 's/\,+\$//' sed.dat
sed -i 's/\,+$//' sed.dat
sed 's/,.*//'
1: You're in single quotes (generally desirable), so "," and "$" are not shell
special characters and need no backslashes.
2: I don't know what your intend with the "+" is. Firstly, by default sed uses
Basic Regular Expressions, which do not include "+". Secondly, "+" is a regexp
character meaning "1 or more or the preceeding item", so you're saying "delete
the first instance of one or more commas". Except that with BREs you're saying
"delete the first comma followed by a plus" because "+" is not special.
I'd test without the "-i" until you have things working.
Cheers,
Cameron Simpson <cs@xxxxxxxxxx>
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx