Question

1). Please explain the commands head, tail, cat, tac, strings. And also run these commands in...

1). Please explain the commands head, tail, cat, tac, strings. And also run these commands in the Linux machine. (Use your own Id’s)

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

1) head : It is a command used to print first N lines from a file to terminal server (Output window).

eg. Fruits.txt

Orange

Mango

Guava

Banana

WaterMelon

Papaya

Cherry

Strawberry

Apple

MuskMelon

head -5 Fruits.txt : This command prints first 5 lines of the file Fruits.txt.

Output :

Orange

Mango

Guava

Banana

WaterMelon

eg2. head Fruits.txt : By default head command prints first 10 lines of the file.So the output will be first 10 lines of the file Fruits.txt.

2) tail : It is a command used to print last N lines from a file to terminal server (Output window).

eg. tail -5 Fruits.txt : This command prints last 5 lines of the file Fruits.txt.

Output :

Papaya

Cherry

Strawberry

Apple

MuskMelon

eg2. tail Fruits.txt : By default head command prints last 10 lines of the file.So the output will be last 10 lines of the file Fruits.txt.

3) cat : It opens the file and prints it on standard output.

a) cat Fruits.txt : This command displays content of file.

Output :
Orange

Mango

Guava

Banana

WaterMelon

Papaya

Cherry

Strawberry

Apple

MuskMelon

b) cat File1.txt File2.txt > File3.txt : This command concatenates content of 2 files and store it in output file File3.txt

File1.txt
Hello

File2.txt
World

File3.txt
Hello
World

4) tac : It concatenates and prints content of file just like cat but in reverse order (ie. last line first) on standard output
eg:

File1.txt

Sam
Paul
Harry

tac File1.txt

OUTPUT :

Harry
Paul
Sam

5) strings : It is used to view all the printable strings/characters from the binary file (non text files).
eg. Let us create a simple c program
$ cat welcome.c
# include <stdio.h>

main()
{
char a[]="strings program";
printf("Welcome to Sample program\n");
system("ls");
printf("%s",a);
}

Create an object file for this c file
$ cc -o welcome welcome.c

$ strings welcome
Output:
/lib64/ld-linux-x86-64.so.2
__gmon_start__
libc.so.6
puts
printf
system
__libc_start_main
GLIBC_2.2.5
l$ L
t$(L
|$0H
Welcome to sample program
strings program

Add a comment
Know the answer?
Add Answer to:
1). Please explain the commands head, tail, cat, tac, strings. And also run these commands in...
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
  • 1). Please explain the commands pwd, cd, cd ~, cd .., ls, mkdir and rmdir. And...

    1). Please explain the commands pwd, cd, cd ~, cd .., ls, mkdir and rmdir. And also run these commands in the Linux machine by using suitable examples. (Everyone should have their own Id's). 2). Please expalin the Absolute path, Relative path and Path completion (with suitable examples) and also Illustrate the difference between them.

  • Please write the Linux commands and run them. h. What is the command or commands that...

    Please write the Linux commands and run them. h. What is the command or commands that would list the contents of the /var/log directory in alphanumeric order? List the command and its output. i. What is the command or commands used to list the files in /var/log in order of their size? List the command and its output. j. What is the command or commands used to list the top 10 file who use the most disk space? What is...

  • In Linux 1 .Read the man pages for the following commands: man, less, cat, cd, ls,...

    In Linux 1 .Read the man pages for the following commands: man, less, cat, cd, ls, grep, and su (or sudo). Select three (3) of these and describe each in your own words. 2. Launch a GUI program, such as gedit, with and without a trailing ampersand (&). When you launch it without an ampersand, use CTRL+Z to put it into the background and see how the program reacts to mouse clicks. Use fg to return it to the foreground,...

  • Revision Question 3 on Linux. Please explain the shell script commands in the context of post...

    Revision Question 3 on Linux. Please explain the shell script commands in the context of post execution. You have just logged in and have a directory called "novel" in your home directory containing the following files: chapter1.docx chapter2.docx chapter3.docx draft.pdf save where "save" is itself a directory and contains the files Attributes.txt draft.pdf.1 draft.pdf.2 draft.pdf.3 indexA.txt indexB.txt list1.txt list2.txt a) Describe the results you would expect when executing the following shell commands: i) ls novel/save/*A* ii) ls novel/*r[23]* iii) rmdir...

  • EXTRA CREDIT 1: Tic Tac Toe (Please use c++ code) also please verify it works because...

    EXTRA CREDIT 1: Tic Tac Toe (Please use c++ code) also please verify it works because I've received wrong answers in the past. Thank You 99 17 30 12 EXTRA CREDIT 1: Tic Tac Toe (10 points) Write a console program that plays Tic Tac Toe with the user. The program displays a 3 by 3 grid, which is initially blank. When the player takes a turn, an X is added to the grid. When the computer takes a turn,...

  • Answer The following Please, Name: Date: Transcription/Translation Practice Worksheet 1. Use the following DNA strand: TAC...

    Answer The following Please, Name: Date: Transcription/Translation Practice Worksheet 1. Use the following DNA strand: TAC GTC ACG AGA TGA GTT ATC ATT A. What is the mRNA synthesized from the DNA strand? B. What is the amino acid sequence that is then translated from this mRNA strand? 2. Use the following DNA stand: TAC TTG GCC ACG GAC TAA CAT GCA A. What is the complementary DNA strand of the above DNA strand? B. Using the complementary DNA strand,...

  • Question 11 1 point possible (graded) The commands in the pipeline $ cat result.txt | grep...

    Question 11 1 point possible (graded) The commands in the pipeline $ cat result.txt | grep "Harvard edX" | tee file2.txt | wc -l perform which of the following actions? From result.txt, select lines containing “Harvard edX”, store them into file2.txt, and print all unique lines from result.txt. From result.txt, select lines containing “Harvard edX”, and store them into file2.txt. From result.txt, select lines containing “Harvard edX”, store them into file2.txt, and print the total number of lines which were...

  • 1. private Node head; private Node tail; public class Node { String name; Node next; Node...

    1. private Node head; private Node tail; public class Node { String name; Node next; Node prev; } public void displayInReverse(){ //write your code here to display names in reverse } 2. public class NodeOne { String name; NodeOne next; public NodeOne(String name) { this.name = name; } } // Complete the code snippet below so that the delete method works properly public void delete(String name) { NodeOne temp = head, prev = head; while (temp != null) { if...

  • Explain the following command scripts in your own words, provide sample scripts, run that script, show...

    Explain the following command scripts in your own words, provide sample scripts, run that script, show screenshot and explain (Windows PowerShell) 1. Restore-Computer 2. Add-Content 3. Get-Content cat/type/gc 4. Set-Content 5. Clear-Content

  • If M = 5.0 kg, what is the tension in strings 1 and 2? Please explain...

    If M = 5.0 kg, what is the tension in strings 1 and 2? Please explain and include all work. Thank you! I will thumbs up. 2. IfM= 5.0 kg, what is the tension in strings 1 and 2? 心 30 T or

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