user3347931
user3347931

Reputation: 319

Bash script to remove dot end of each line

Unix command to remove dot at end of each line in file.

Sample rec in file

11234567                 0.
23456789              5569.
34567810                 1.
10162056                 0.

Upvotes: 9

Views: 13735

Answers (3)

keelerm
keelerm

Reputation: 2943

sed -i 's/\.$//' /path/to/file

This will match a literal period that is anchored to the end of the line, and replace it with nothing. The -i tells sed to make the change inline.

Upvotes: 0

sehe
sehe

Reputation: 393134

 sed -e 's/\.$//'

done. (padding to make answer long enough. grumble)

Upvotes: 2

jaypal singh
jaypal singh

Reputation: 77105

Just use sed:

sed 's/\.$//' yourfile
  • Escape the special character . using \.
  • Put an achor $ to only remove it from the end.
  • To make infile changes use -i option of sed.

Upvotes: 10

Related Questions