开发者

How to remove first comma on each line in a file

开发者 https://www.devze.com 2022-12-24 00:59 出处:网络
Remove fi开发者_如何转开发rst comma on each linein a file. I presume sed is needed.sed sed -i.bak \'s/,//\' file

Remove fi开发者_如何转开发rst comma on each line in a file. I presume sed is needed.


sed

sed -i.bak 's/,//' file

awk

awk '{sub(",","")}1' file >temp; mv temp file

shell

while read -r line
do
 echo "${line/,/}"
done <"file" > temp
mv temp file


Yes, sed will do it.

sed s/,// < filename


For first comma:

sed '/,//' < file

If first comma is first character:

sed '/^,//' < file


Yes,

first comma sed '/,//' < file

first character that is a comma sed '/^,//' < file

USEFUL ONE-LINE SCRIPTS FOR SED


sed '/^,//' < file
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号