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
精彩评论