class: center, middle # CSCI-UA 480.10: OSSD
## useful commands .author[ Instructor: Joanna Klukowska
] .license[ Unless noted otherwise all content is released under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). ] --- # `diff` - see differences between two files (works for text) - options for ignoring white space --- # `grep` - print lines from the input file (or stream) that match a given expression - find all occurences of the string "Joanna" in all files in the current directroy (do it recursively) ```bash grep -R "Joanna" * ``` - find all occurences of the string "open source" in the files stored in `~/Data/NYU_Teaching/csci480_ossd/`, don't go into subdirectories ```bash grep "open source" ~/Data/NYU_Teaching/csci480_ossd/* ``` --- # `sort` - sort the lines coming from the input file or from standard input - default order: alphanumeric - `-n` option uses numerical order - `-r` option reverses the order --- # `cut` - print specific parts (columns, characters) of the input file/stream - options allow to select columns (individual 1-base numbers) or ranges of columns (comma-separated values: 1,3,8 or range: 3-7) - `-f` option specifies column numbers (default column separator is a tab) - `-c` option specifies character positions - `-d` option changes the default separator --- # `paste` - combines input from multiple files into a single "line by line" output --- # `find`
--- # `find -name` find files with names matching a string - find all files in my home directory matching string "ossd" ```bash find ~ -name "*ossd*" ``` - `~` shortcut for the home directory of the current user - `*ossd*` pattern to match - find all files in the current working directory matching string "bugs" ```bash find . -name 'bugs' ``` - find all files in the specified directory matching the string "cs102" at the start of the file/directory name ```bash find . -name 'cs102*' ``` --- # `find -size` find files based on their size - find all files in the current working directory that are larger than 512M ```bash find . -size +512M ``` --- # `find -mtime` (`-atime`) find files that have been modified (`mtime`) or accessed (`atime`) within specified number of days (for minutes use `mmin` and `amin` options) - find all files in the current working directory that have been modified within the last two days ```bash find . -mtime -2 ``` --- # `find -perm` find files with specific permissions - find all files in user's home directory with wide open permissions ```bash find ~ -perm 777 ``` --- - `find` all image files larger than 3MB ```bash find ~ -size +3M -a \( -name "*.jpg" -o -name "*.png" -o -name "*.gif" \) ```` --- ---