Quantcast
Channel: User ozzy - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 31

Answer by ozzy for how to find & replace a file path listed in a file

$
0
0

You could use:

sed -i -E -e 's/(\/.*\/)(.*\.idt)/\2/' file_list

This performs an in-place (-i) replacement of all /..../filename.idt filepaths with filename.idt ("all" as in: the first occurrence on each line of a certain file). If there is no absolute path preceding the filename, the regex does not match, and nothing happens. The file_list can be replaced with an *.xml or the like at your command prompt. You may want to try running the command without the -i option first, to see the output before writing it to disk.


Viewing all articles
Browse latest Browse all 31

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>