Chapter 3 Flashcards
What does man file do?
Determines file type
How do we create a directory with a subdirectory?
Mkdir -p dir/subdir
When working with directories (as opposed to files), which command does not need a recursive flag?
mv
What are the five key flags in the tar command?
- c create archive
- x extract archive
- r append to an archive
- f read from or write to a file
- t list the contents of the archive
How to get a big picture overview of the filesystem?
df -h
How to get a big picture overview of the filesystem?
df -h
How do we create an archive with tar and all the files that are called “file_[smth]?
tar cf archive.tar file_*
How do we add a file to an archive?
tar rf archive.tar
How do we check an archive for a specific file with tar? hint: first display the entire archive and then look for what you need
tar tvf archive.tar | grep extra.txt
t = tail v = verbose
How do we compress a normal archive to a maximum degree?
gzip -9 archive.tar
How do we create a bzip2 archive with tar?
tar cjf archive.tar.bz2
How to create a zip archive?
zip -r archive.zip file1_*
How do we determine number of words in a file?
wc
What does wc do?
It counts words
How can we count the number of lines rather than words in an input file?
wc -l
How do we list the recently used commands starting with cat? (or anything else really, cat si just one example)
!cat
What does the cut command do?
It removes sections from lines of files
What does the cut command do?
It removes sections from lines of files
What’s the basic syntax of reading input from a file?
command < file
What’s the basic syntax of sending input to a file?
command > file
What’s the basic syntax of appending input to a file?
command»_space; file
How do we look for all results that end - END! - with Apple or Ball?
grep -E “Apple$|Ball$”
What do we find when we look for grep -E “Ap*le”
A followed by 0 or more p’s followed by “le”
What’s the difference between looking for “Ap*le” and “Ap+le”?
the plus means 1 or more p’s and the star means 0 or more p’s