|
|
Advanced File Commands
- grep
- Extremely useful tool to search for text in a file.
grep text filename
- sed
- Stream EDitor: Allows you to apply various commands to each line of
input. Has been somewhat overshadowed by perl.
- awk
- Counterpart to sed (named after its creators, Aho, Weinberger, and
Kernighan). Awk performs actions on lines that match certain patterns.
- cut
- Cut is used to print certain fields of each line in a file.
For example, each field of the unix password file is separated by a
colon. To read just the usernames, you could use:
cut -f 1 -d:
- paste
- Paste takes two files and merges them line by line by concatenating
the lines of the second file to the ends of the lines of the first file.
- sort
- Sort is a useful tool that can sort a file by alphabetical or numeric
content.
- uniq
- UNIQue: Finds lines in a sorted file that are unique. Can be used to
eliminate duplicates, eliminate non-duplicates, etc.
|