I want to edit the file contents in the 2nd row 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
resultant 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.there are multiple files in a folder likes this ,i want to change the contents for all .ctl file in the 2nd row similarly.
Operating system details Linux 2.6.32 -696.30.1.e16
GNU/linux
Best Answer
Try
Redirect
>
into temp file, andmv
/cp
back to original file if desired. For multiple files, run in afor
loop for all relevant files.