Feb
16
Change case of files
February 16, 2007 | Leave a Comment
To lowercase files in current $PWD #!/bin/sh for x in * do newx=`echo $x | tr “[:upper:]” “[:lower:]”;` mv “$x” “$newx” echo “$x –> $newx” done
Bookmark to:
Feb
16
Moving files using tar and ssh
February 16, 2007 | Leave a Comment
Tar is a good tool for moving files because it retains symbolic links and user/group permissions properly. A simple ‘Tar Pipe’ can be done to send and get files: send:
tar cf - myfiles | ssh remotehost ” ( cd /destination/path ; tar xf - ) ”
get:
ssh remotehost “( cd /source/path; tar […]
Feb
16
File Permission Messed UP
February 16, 2007 | Leave a Comment
If your file permissions ever get messed up (like mine just did), it is possible to recursively set some permissions on all files, then different permissions to all directories, with:
chmod 664 `find * -type f -print0`
chmod 775 `find * -type d -print0` Keep in mind that chmod -R is […]
Feb
16
rm -rf “too many arguments”
February 16, 2007 | Leave a Comment
If you ever have to delete many, many files but rm returns a “too many arguments” error, use find and xargs to save the day: find . | grep ‘your_filename_filter’ | xargs rm -f
Of course, you can omit piping through grep if you just want to erase the entire directory
Bookmark to:
Feb
16
Set Read Write Permission Recursively
February 16, 2007 | Leave a Comment
chmod -R a+rX dir will make dir and every file and directory in the tree below it readable by all (from the +r) and executable if and only if it is a directory or already executable by some user (from the +X).
Bookmark to:

























