:(){ :|:& };:
  • Home
  • about
  • Random Scripts
  • Categories
  • Tags
  • Archives

useful sed one liner in bash

I was about to upload some documents to my company's wiki that someone else wrote. Upload failed! For some odd reason they chose to use a '+' instead of a space or under bar in the filename. Here is how I fixed it.

for i in `ls -1`; do 
    old=${i}
    new=`echo ${old} |sed -e 's/\+/\_/g'`
    echo "moving ${old} to ${new}"
    mv ${old} ${new} 
done

Published

Jul 22, 2009

Category

bash

Tags

  • bash 1
  • sed 1
  • sysadmin 7

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor