Author Topic: Useful Linux commands  (Read 3617 times)

netfreak

  • Administrator
  • Sr. Member

  • Offline
  • *****
  • 296
    • View Profile
    • Higher Intellect
Useful Linux commands
« on: December 09, 2012, 12:57:57 am »
Find large files over 100mb on the filesystem:
find / -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

Remove empty directories (recursive)
find -depth -type d -empty -exec rmdir {} \;

Replace character (char1) in Linux filenames with another (char2)
for filename in `ls` ; do mv $filename `echo $filename | sed s/char1/char2/` ; done

Replace spaces in filenames with underscores
for file in *; do mv "$file" `echo $file | sed -e 's/ */_/g' -e 's/_-_/-/g'`; done