Showing posts with label Sed. Show all posts
Showing posts with label Sed. Show all posts
Monday, May 03, 2010
Tuesday, July 07, 2009
List only directories
ls -F $1 | grep \/ | sed -e 's/\/$//g'
Rename extension of all files in a folder
Here is a way to do this from command line
ls *.sh | sed 's/\(.*\)\.sh/ & \1.pl/' | xargs -L1 mv
Ok there are four commands here all piped.
ls
sed
xargs
mv
I used ls to filter all .sh files.
I used sed to substitute all .sh to .pl. What it does is creates argument for mv command. Test it with ls *.pl | sed 's/\(.*\)\.pl/ & \1.sh/'
I used xargs with mv to move sh to pl. the –L switch is used to get input form sed pipe
ls *.sh | sed 's/\(.*\)\.sh/ & \1.pl/' | xargs -L1 mv
Ok there are four commands here all piped.
ls
sed
xargs
mv
I used ls to filter all .sh files.
I used sed to substitute all .sh to .pl. What it does is creates argument for mv command. Test it with ls *.pl | sed 's/\(.*\)\.pl/ & \1.sh/'
I used xargs with mv to move sh to pl. the –L switch is used to get input form sed pipe
Subscribe to:
Posts (Atom)