103.2 Process text streams using filters Flashcards
How do you use the md5sum command?
md5sum
What is a message digest?
it calculates and checks a file’s hash based on the MD5 algorithm.
It calculates and checks a file’s hash based on the MD5 algorithm.
What command counts the words in a file?
#wc file.txt #wc -w file.txt (for words alone) #wc -l file.txt (for number of lines)
What command is used to count lines in a file?
#nl file.txt or (will not count empty lines) #nl -b a file.txt (will count empty lines too)
How do you read a file live as lines are added to it?
tail -f file.txt
What does the #head command do?
It displays only the first 10 lines of a file. If more are desired, type: #head -n file.txt
What does the #tail command do?
By default it gives the last 10 lines of a file.
If more are desired, then type: #tail -n file.txt
How do you exit from a file read with #less?
Hit the ‘q’ key.
Within a file read with #less, when searching, how do you move between matching results?
n for next match
p for previous match
How do you search for a keyword within a file read with #less?
Type forward slash / and the keyboard
Is #less read only?
Yes, it is only for viewing, allowing for paging up and down within the file and it allows for searching keywords.
What is the original use of the #cat command?
To concatenate or join files together.
cat file1 file2 > newfile
What does the #split command do?
It splits a file up into individual pieces of up to 1000 lines per default (can be changed).
When you run the #split command (#split , what type of output does it give?
A file called xaa
How do you break up a large file in pieces at a desired size?
#split -b 100 (bytes) #split -b 100K (kilobytes) #split -b 100M (megabytes) #split -b 100G (gigabytes)
What does the #cut command do?
It extracts columns or fields of data from a file.
How do you swap all capital letters in a file to lowercase in one go?
#tr #cat file.txt | tr 'A-Z' 'a-z'
What does the #paste command do?
It combines or merges lines of files in parallel.
What command do you use to replace or swap a character for another within a file?
#tr (it needs to be fed the stdout of cat as stdin) #cat file.txt | tr 'x' 'y'
What command is used to display unique lines of a file?
uniq
How do you sort the contents of a file by numerical order?
sort -n
What is the #sort command used for?
sort is used to sort or merge files.
What other commands besides md5sum can you use to check a file’s integrity?
#sha256sum #sha512sum