Reputation: 41
I have a file name abc.TXT. The contents of the file are
./pub/index.html
./manifest.bak
./manifest.rel
./ns/GSCT_ASNShipmentInfo_E1/node.idf
./ns/GSCT_ASNShipmentInfo_E1/E1/svcUpdateVR01ForOP/flow.xml.bak
./ns/GSCT_ASNShipmentInfo_E1/E1/svcUpdateVR01ForOP/node.ndf
./ns/GSCT_ASNShipmentInfo_E1/E1/svcUpdateVR01ForOP/flow.xml
I want to remove the .(dot) from each line and save the content to a new file bcd.TXT. The content in bcd.TXT should be
/pub/index.html
/manifest.bak
/manifest.rel
/ns/GSCT_ASNShipmentInfo_E1/node.idf
/ns/GSCT_ASNShipmentInfo_E1/E1/svcUpdateVR01ForOP/flow.xml.bak
/ns/GSCT_ASNShipmentInfo_E1/E1/svcUpdateVR01ForOP/node.ndf
/ns/GSCT_ASNShipmentInfo_E1/E1/svcUpdateVR01ForOP/flow.xml
Upvotes: 2
Views: 69
Reputation: 67231
Using perl:
perl -pe 's/\.//' abc.TXT > bcd.TXT
For in place replacement:
perl -pi -e 's/\.//' abc.TXT
Upvotes: 0
Reputation: 77105
fedorqui's answer will remove any first character. So if you are not sure if it is a .
then you can tell sed
to remove only if you see a .
Using:
sed 's/^\.//' abc.TXT > bcd.TXT
tells sed
that if first character of my file (denoted with ^
) is a literal .
(denoted with \.
), then replace it with nothing.
If you want to make changes in your existing file you can use -i
option. This will make the changes in your file.
Upvotes: 1
Reputation: 289755
With sed
:
$ sed 's/.//' abc.TXT > bcd.TXT
$ cat bcd.TXT
/pub/index.html
/manifest.bak
/manifest.rel
/ns/GSCT_ASNShipmentInfo_E1/node.idf
/ns/GSCT_ASNShipmentInfo_E1/E1/svcUpdateVR01ForOP/flow.xml.bak
/ns/GSCT_ASNShipmentInfo_E1/E1/svcUpdateVR01ForOP/node.ndf
/ns/GSCT_ASNShipmentInfo_E1/E1/svcUpdateVR01ForOP/flow.xml
sed s/.//
replaces a character with nothing once every line. That is, it removes the first character.
Upvotes: 1