0

A very generic question but I am looking for the simplest way solve this very quickly and efficiently
I have a file with a very large number of lines which looks like this

  451267 sample1.txt  
  157444 sample2.txt  
  134864 sample2.txt

and I want result where the file(same or new) looks like

  451267 sample1   
  157444 sample2  
  134864 sample2
0

The easiest way to do this is with sed I believe.

sed 's/.txt//g' file

This command replaces the pattern '.txt' with nothing.

  • 1
    uuoc, better: sed 's/.txt//g' file – RoVo Oct 4 '18 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.