Question

Post-Lab 2: GNU and UNIX commands Keywords: • Sort • head tail • Pipe (D • Redirection ) • alias • Wildcards • Metacharcters
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

  1. To create a directory- mkdir dir1 ( we use this command to create a directory in unix)

To change a directory- cd dir1 ( this command is used to change a directory in unix)

2- With pipelines- head -5 hello1.txt | tail -3 (this command will extract lines from 3rd to 5th)

head -5 hello1.txt (this command will display starting 5lines of a file.)

tail -3 hello1.txt (this command will display last 3lines of a file.)

With redirection-

head -5 hello1.txt >sample.txt (this command will redirect lines in sample.txt file)

Tail -1 hello1.txt >sample.txt

3- cp my.txt hello2.txt (this command will create a redundant file of my.txt)

sed 3d  hello2.txt (this command will delete 3rd line of a file)

sed ‘/is/d’ hello2.txt (this command will delete occurrence of is in a file)

sed ‘/^$/D’ hello2.txt (this command will display non-blank lines of a file.)

4- To delete a file type command - rm hello2.txt (after enter press it will prompt type 'Y' to remove or type 'N' not remove.

This is my file content. head and tail commands used separately.

[root@localhost ~]# ls dos hello. c hello1.txt [root@localhost.~]# cat hello1.txt unix is an operating system. it is very eas

head and tail command used with pipelinerootalocalhost 15 dirldos hello.c hello1.txt [root@localhost ~]# cat hello1.txt unix is an operating system. it is very easy

head and tail commands used with redirection.[root@localhost ms] # root@localhost # head -5 hell01.txt tail -3 Rinux is also an operating system. it is open source. it is

sed command to delete a specific line.

Susah ww [root@localhost ~]# sed d hell01.txt unix is an operating s it is very easy to learn. it is open source. it is very

Add a comment
Know the answer?
Add Answer to:
Post-Lab 2: GNU and UNIX commands Keywords: • Sort • head tail • Pipe (D •...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 2 0/1 point (graded) What happens when you remove a directory using the command rm...

    Question 2 0/1 point (graded) What happens when you remove a directory using the command rm -r? You cannot remove a directory using the rm command. You permanently remove the entire directory, including all files and subdirectories. You move the entire directory to a trash folder, but it can be restored later. You get a warning message asking if you want to proceed, then you delete the directory. incorrect Answer Incorrect: Try again. Unix does not warn you before permanently...

  • The purpose of this lab assignment is to practice searching in Unix and using regular expressions....

    The purpose of this lab assignment is to practice searching in Unix and using regular expressions. Task A: Use the find command to find all directories under /pub/cs/ whose name is cs160a. Be sure to only display the results that match, do not display any error output. Hint: use: 2>/dev/null. Task B: Create a one-line command, using he famous.dat file, to add the word " STREET" to the address, for all who live on 2nd or 3rd. For example: '2nd'...

  • LINUX QUESTIONS (dont have to display output, I will be running these commands myself to check...

    LINUX QUESTIONS (dont have to display output, I will be running these commands myself to check the output) Display the command(s) used to do the following: create an empty file called history by using just a redirection operator. Verify and show. Show/verify all results (i.e., all commands and their corresponding outputs). Wait 1 minute or more and then display the command(s) used to do the following: change the timestamp on the history file you just created. Verify/display the change. Show/verify...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT