Modify file names containing spaces using perl
Many a times we see some configuration files which have list of paths like:/abc/123_1/1tvd/fiel.txt /abc/123 r/1tvd/fie2l.txt /abc/123 a/1tvd/fie3l.txt /abc xyz/123/1tvd/fie4l.txtand some times the spaces create a lot of problems while we use those configuration files.
in such cases we need to make those directory names as
/"abc xyz"/123/1tvd/fie4l.txtBut how do we do it across the complete file?
Below is the perl way to do it:
perl -F"/" -ane 'foreach (@F)
{if(/ /){$_="\"".$_."\"";}}
print join "/",@F;' config_file
But yes there can be other ways too like in awk..png)







I am a software programmer working in India. I usually like to blog in my free time.
Hi nnice reading your post
ReplyDelete