Unix Interview Questions Flashcards

Terms Definitions
How to print/display the first line of a file?
Sentence: There are many ways to do this. However the easiest way to display the first line of a file is using the [head] command.
How to print/display the last line of a file?
Sentence: $> sed '2,$ d' file.txt
How to print/display the last line of a file?
Sentence: The easiest way is to use the [tail] command.
If you want to do it using [sed] command, here is what you should write:
Sentence: $> sed -n '$ p' test From our previous answer, we already know that '$' stands for the last line of the file. So '$ p' basically prints (p for print) the last line in standard output screen. '-n' switch takes [sed] to silent mode so that [sed] does not print anything else in the output.
How to display n-th line of a file?
Sentence: The easiest way to do it will be by using [sed] I guess. Based on what we already know about [sed] from our previous examples, we can quickly deduce this command:
How to remove the first line / header from a file?
Sentence: We already know how [sed] can be used to delete a certain line from the output – by using the'd' switch. So if we want to delete the first line the command should be:
/ 6
Term:
Definition:
Definition:

Leave a Comment ({[ getComments().length ]})

Comments ({[ getComments().length ]})

{[comment.username]}

{[ comment.comment ]}

View All {[ getComments().length ]} Comments
Ask a homework question - tutors are online