CH10 : Working with file content Flashcards
head
You can use head to display the first ten lines of a file.
head -4 /etc/passwd
displays
dislplays the first n line of a component
head can also display the first n bytes.
root:x:0:0:roopaul@debian7~$
tail
display the last ten lines of a file.
u can give tail the number of lines you want to see.
cat
The cat command is one of the most universal tools
yet all it does is copy standard input to standard output
you can use cat to display a file on the screen
If the file is longer than the screen, it will scroll to the end.
cat is short for
concatenate.
Cat - create files
You can use cat to create flat text files.
$ cat > winter.txt
here directive
You can choose an end marker for cat with «_space;as is shown in this screenshot. This construction is called a here directive and will end the cat command.
Cat - copy files
cat file1 > file2
coping the content of file1 to file2
viewing file2 conent
$cat file2
tac
reverse the file content
more and less
he more command is useful for displaying files that take up more than one screen.
More will allow you to see the contents of the file page by page. Use the space bar to see the next page, or q to quit.
Some people prefer the less command to more.
strings
With the strings command you can display readable ascii strings found in (binary) files.