I want to edit the file contents in the 2nd line and 2nd column ,which is a file name from that I want to remove the part after the last underscore and before the file extension .
The contents of the file looks like below Input file contents
No|filename|count 01 |com_101_00000_0001_a234.txt|100
expected output file content
No|filename|count 01 |com_101_00000_0001.txt|100
The number of underscores may vary depending upon the file names present inside the .ctl files. Also there are multiple files in a folder likes this ,i want to change the contents for all .ctl files in the 2nd line similarly.
Operating system details Linux 2.6.32 -696.30.1.e16 GNU/linux
I tried with the below solution
cat com_101_00000_0001.ctl | sed 's/(.)_[^_](.[^_]*)$/\1\2/'
This edited the file contents but shows the contents in the putty console itself ,what i want is to modify the original files in a particular path in server
Please tell where it went wrong