| find files from current directory down | find . -name filename |
| find files from home directory using wildcards | find ~ -name filenam* |
Wednesday, March 30, 2011
Find Files
Directory Listing
| show subdirectory | pwd |
| list files and directories | ls |
| list files and directories (one per line) | ls -l |
| list files beginning with 'Adams' | ls adams* |
| list files by screenful | ls | more |
Counts
| count files in a directory | ls | wc -l filename |
| count lines files | wc -l filename |
| count lines words and bytes | wc filename |
| count words files | wc -w filename |
| write a file count to a file | ls | wc -l > file.ext |
Copy / Move
| concatenate files together in new file | cat oldfile1.ext oldfile2.ext > bothfiles.ext |
| copy a file and prompt before overwriting | cp -i existingfile newfile |
| copy top # lines of a file to a new file | head -# filename > newfilename |
| move a file and prompt before overwriting | mv -i existingfile newfile |
Compare Files and Directories
| compare two directories | diff /directory1 /directory2 |
| compare two files | cmp file1 file2 |
| compare two files and show specific differences-i=ignore case-b=ignore blanks-w=ignore spaces and tabs | diff -iwb file1 file2 |
| compare two files side-by-side| lines are the same< line is in first file only> line is in second file only | sdiff file1 file2 |
| compare two files side-by-side showing only differences | sdiff -s file1 file2 |
Change / Make Directory
| make a directory | mkdir subdir |
| change to a subdirectory beneath where you are | cd subdir |
| change to a subdirectory of the root | cd /subdir |
| change to a subdirectory under your home directory | cd ~/subdir |
| change to home directory | cd |
| change up one level | cd .. |
Subscribe to:
Posts (Atom)