Question

Write Linux command for each question. Please use one single commend to do following process. Q1:...

Write Linux command for each question. Please use one single commend to do

following process.

Q1: Display all lines of list1.txt and list2.txt containing the letter ‘p', and sort the result.

Q2: Append “file1.txt” and “file2.txt”, and redirect to “file3.txt”.

Q3: Sort “file3.txt”, and redirect the result to file “file4.txt”

Q4: Use shorthand way to change the permission of “file3.txt” to “user - write read

execute, group - read execute, other - execute”.

Q5: Extract first column from “file3.txt”, and redirect to “file5.txt”.

Q6: Extract second and third column from “file4.txt”, and append result to “file5.txt”.

Q7: Replace all “20” to “200” in “file5.txt”, and redirect result to “table7.txt”.

Q8: Remove all duplicate lines from “file4.txt”, and redirect the result to “file8.txt”.

Q9: Display sorted filename in the current path.

Q10: Redirect sorted filename in the current path to “file9.txt

It only needs to be the command to as if there was information in the files. So write only the command.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Linux Commands

1.sort  grep -h p list1.txt list2.txt

In the above command grep is a filter used to search a file for particular pattern.  -h for finding pattern , p is the pattern and list1 and list2 are file name. sort used for sorting.

2. cat file1.txt file2.txt >> file3.txt

3. sort file3.txt > file4.txt

4. chmod 751 file3.txt

5. cut -c 1 file3.txt > file5.txt

6. cut -c 2,3 file4,txt >> file5.txt

7. sed 's/20/200/g' file5.txt >table7.txt

8. uniq file4.txt > file8.txt

9. ls -1 | sort

10. ls -1 | sort > file9.txt

SUMMARY: chmod used for permission i.e, access mode of a file. cut is used to cut particular field or column , In the above q 5 & 6 uses cut for columns cut .sed used to replace i.e, called as Stream Editor. uniq is used to filter reapeated lines. sort used for sorting purpose. cat is used for concatination. > can be used for redirection and >> for appending purpose.

Add a comment
Answer #2

Q1: grep "p" list1.txt list2.txt | sort 

Q2: cat file1.txt file2.txt >> file3.txt 

Q3: sort file3.txt > file4.txt 

Q4: chmod u=rwx,g=rx,o=x file3.txt 

Q5: cut -f1 file3.txt > file5.txt 

Q6: cut -f2,3 file4.txt >> file5.txt 

Q7: sed 's/20/200/g' file5.txt > table7.txt 

Q8: sort -u file4.txt > file8.txt 

Q9: ls | sort 

Q10: ls | sort > file9.txt

answered by: Hydra Master
Add a comment
Know the answer?
Add Answer to:
Write Linux command for each question. Please use one single commend to do following process. Q1:...
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
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
ADVERTISEMENT