Browse Docs

๐Ÿ”Ž Search, Find & Compare

Find files quickly

1locate <pattern>    # find a directory or file quickly (uses an index); a brand-new file won't be found.
2updatedb            # update the locate index.

Open a file

1view <file>             # opens a read-only vi view (preferred if you just want to search/view).
2gzcat / zcat <file.gz>  # read a gzipped file.

Info on a file or directory

1stat </my/file>      # all info about a file (inode, creation, modification, access dates, etc.).
2stat -f <FS>         # info about a filesystem.
3stat -c%s $LOGFILE   # [scripting] get a precise value (size, modification date, etc.).

grep

 1grep -w 'xyz'                # match the whole word.
 2grep -x 'Hello, world!'      # the whole line must match.
 3grep -c <pattern>            # count the matching lines.
 4grep -l "ERROR:" *.log       # search all .log files, list the files that match.
 5grep -L <pattern>            # inverse: list the files that do NOT match.
 6grep -f <patternfile> <file> # apply the patterns read from patternfile.
 7grep -i <pattern>            # ignore case.
 8grep -v <pattern>            # return the lines that do NOT match.
 9grep -m x <pattern>          # stop after x matching lines.
10grep -n <pattern>            # show the line number.
11grep -q <pattern>            # quiet: exit 0 if found, 1 (or 2) otherwise (for scripting).
12grep -s <pattern>            # suppress permission/inexistent-file error messages.
13grep -H <pattern>            # show the filename next to each matching line.
14grep -h <pattern>            # do not show the filename (default behaviour).
15grep -A x <pattern>          # also show x lines After.
16grep -B x <pattern>          # also show x lines Before.
17grep -C x <pattern>          # show x lines of context (A + B).
18grep -a <pattern> <binary>   # search a binary file as if it were text.
1egrep = grep -E   # for complex regular expressions.
1# extract the 3rd field, then cut:
2cat file | grep /u01/grid/19c | awk '{print $3}' | cut -f2 -d'"'
3# is equivalent to:
4cat file | grep -o /u01/grid/19c
Sunday, October 4, 2026 Thursday, August 17, 2023