I have a bash script which generates text file. But I want to delete current path portion from each line. I tried to run "cut -d'/'
--complement -s -f1-4" command. But I want some dynamic way to do it. Can someone please help me with it? Thank you !
Sample text file:
Using sed you can do:
sed 's~^/local/name1/test/~~' file dir/file1.c dir/subdir/file2.h dir2/file3.txt
If your current path is saved in a variable
p then use:
sed "s~^$p~~" file