linux - Shell script handle string with sed -


i have text file, each line 1 or more file paths separated space, file has suffix dl, e.g.

/some/path/file.dl /some/other/path/file2.dl /some/other/path2/file3.dl /some/other/path3/file4.dl /some/other/path4/file5.dl ... ... 

now need transform above file text file. first file of every line should changed /out/p{filename}.h:, {filename} original file name without directory , suffix. e.g.

/out/pfile.h: /out/pfile2.h: /some/other/path2/file3.dl /out/pfile4.h: /some/other/path2/file5.dl ... ... 

so how can write linux shell script?

try command:

$ sed -r 's@^\s*/(\s*)\.dl@/out/p\1.h:@' input  /out/pfile.h: /out/pfile2.h: /some/other/path2/file3.dl /out/pfile4.h: /some/other/path4/file5.dl 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -