files
Files
File Types
$ ls -l # shows type in the first character of the file permissions column where type is: * - : regular file * d : directory * c : character device file * b : block device file * s : local socket file * p : named pipe * l : symbolic link
$ ls -F # appends symbols to filenames where symbol is: * @ : symbolic link (or that the file has extended attributes) * * : executable * = : socket * | : named pipe * > : door * / : directory
Soft link
$ ln -s filename linkname $ ln -s /media/john/Seagate\ Expansion\ Drive/ /seagate $ unlink /seagate
filename wildcards
$ rm *.?????[!3]?[!1].*.sql # delete all files not in march and not day 1 $ rm *.?????[!3][!0]?.*.sql # delete all files not in march and not day 11, 21, or 31
tree
$ tree # draw tree structure of folders
find
$ find . -name *.plugin
$ find . -name *.plugin 2>/dev/null
$ find /media/seagate/media/ -name Thumbs.db -exec rm {} \; # delete files across folders
$ find . -name "*.js" -exec java -jar compiler.jar --js {} --js_output_file new{} \;
$ find . -name "*.jpg" -exec convert {} -resize 1920x1080 ../assets_youtube/{} \;
find unique list of file types
$ find ../ -type f | awk -F. '!a[$NF]++{print $NF}'
find and execute command on files across files
$ find /media/seagate/media/ -name Thumbs.db -exec rm {} \; # delete files across folders
$ find ../ -type f \( -name "*.jpg" -o name "*.JPG" \) -exec rm {} \;
$ find ../ -type f -name "*.JPG" -exec rename s/JPG/jpg/ {} \;
find a file anywhere on the disk and ignore the “Permission denied” messages
$ find / -name Wire.h 2>&1 | grep -v "Permission denied"
grep
$ grep -r "progressive" .
rename
$ rename s/JPG/jpg/ *
copy files
$ mv SRC DEST $ cp SRC DEST $ scp SRC DEST $ rsync SRC DEST
synchronize two external hard disks, dry run, real thing, ending slash required
rsync --dry-run --itemize-changes -avh /media/john/My\ Passport/pub/ /media/john/Seagate\ Expansion\ Drive/pub/ rsync -avh /media/john/My\ Passport/pub/ /media/john/Seagate\ Expansion\ Drive/pub/ --dry-run --itemize-changes --delete, delete extraneous files from destination (dest will mirror src) -a --archive, equivalent to -rlptgoD -r --recursive -l --links, copy symlinks as symlinks -p --perms, preserve permissions -t --times, preserve modification times -g --group, preserve group -o --owner, preserve owner -D preserve device files, preserve special files -v --verbose -h --human-readable number formats
sync songs from hard disk to phone, skipping the cover art
rsync --delete -avh -e "ssh -p 2222" --exclude '*.jpg' /media/passport/pub/songs/ '192.168.1.100:/storage/emulated/0/media/songs/'
files.txt · Last modified: 2024/01/06 07:11 by jhagstrand