开发者

How to remove first comma on each line in a 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜