6. File Viewing and Manipulation and Text Editors Flashcards
Which commands are used to view files one page at a time?
less filename.ext
more filename.ext
Which command is used to view the first ten lines of a file?
head filename.ext
Which command is used to view the first specific number of lines of a file?
head -number filename.ext
e.g
head -3 filename.ext will display the first 3 lines of a file
There is a command that works exactly like the head command but starts reading files form the end what is the name of that command?
tail
tail filename.ext will show the last 10 lines of a file
tail -n 3 filename.ext will show the last 3 lines of file
What command is used to count the lines, words, and characters in a given file?
wc filename.ext
result: lines words characters
How would you specify you want to count only the number of lines, words, or characters in a given file?
wc -l filename.txt => for lines
wc -w filename.txt => for words
wc -c filename.txt => for characters
What default Linux text editors do you know?
Vi
Nano
In Vi or Vim, how do you open/create a new file?
vim filename.ext
In Vi or Vim, how do you switch to insertion/editing mode once a file is open?
You press i
In vi or vim, how do you go back to normal mode from insertion mode?
press esc
In vi or vim, how do you save your file?
:w
and press enter
In vi or vim, how do you exit the file?
:q or :q! to force quit without saving