LAMP How To - Open Source At Work

Only Passion Matters

Entries Tagged ‘sed’

Bash: Simple command to mass replace content in directory

Imagine that we need to mass change the content in certain directory. A combination of find and sed can save the day. It is very to do it in perl as well.

find /your/dir -type f | xargs sed -i ’s/old/new/g’

Share and Enjoy:

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • StumbleUpon
  • Technorati
  • LinkedIn
  • MySpace
  • Slashdot
  • TwitThis
  • Yahoo! Buzz

mass files with illlegal names in linux

Windows are notorious for having files that are named with illegal characters like ?, & spacing…etc. To mass rename them, remember to use quotations in the mv command. eg

for i in *; do mv “$i” newfile_”$i”; done;

It took me along time to figure out that the error lies in the mv command and not the [...]

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • StumbleUpon
  • Technorati
  • LinkedIn
  • MySpace
  • Slashdot
  • TwitThis
  • Yahoo! Buzz