A file has 1000 lines and i want to display only 1st line
how to do it?
pls ..tel me

Answers were Sorted based on User's Feedback



A file has 1000 lines and i want to display only 1st line how to do it? pls ..tel me..

Answer / sandip01

sed -n '1p' or head -1

Is This Answer Correct ?    31 Yes 0 No

A file has 1000 lines and i want to display only 1st line how to do it? pls ..tel me..

Answer / siddharth

cat fileName | head -n 1

Is This Answer Correct ?    13 Yes 1 No

A file has 1000 lines and i want to display only 1st line how to do it? pls ..tel me..

Answer / radhakant kumar

awk '{if(NR==1) print $0}' filename

Is This Answer Correct ?    9 Yes 2 No

A file has 1000 lines and i want to display only 1st line how to do it? pls ..tel me..

Answer / namdeo patil

head -n 1 filename

Is This Answer Correct ?    8 Yes 2 No

A file has 1000 lines and i want to display only 1st line how to do it? pls ..tel me..

Answer / raja

head -n <filename>

here n for no.of records we want.

ur quention my ans is
head -1 <filename>

Is This Answer Correct ?    7 Yes 1 No

A file has 1000 lines and i want to display only 1st line how to do it? pls ..tel me..

Answer / hari

head 1 file

Is This Answer Correct ?    2 Yes 0 No

A file has 1000 lines and i want to display only 1st line how to do it? pls ..tel me..

Answer / eswar

head -n 1 filename

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Unix Commands Interview Questions

what is the command to get help on a UNIX terminal?

5 Answers  


Which mode is used for allowing file write,read and append mode?

9 Answers   BitWise, TM,


what is mount ,tell me about mount ,how can u use in real time project??

12 Answers   Symphony,


Explain the read, write, and execute permissions on a UNIX directory.

5 Answers  


what do you understand by 'building block primitive'?

0 Answers   Infosys,






Hi All, Can you please let me know how to grep for a particular pattern in unix. I want to print the dates from the file exp.txt. the date pattern is DD:MM:YYYY, I just want to print all the dates from the file exp.txt.

8 Answers   Concentrix, IBM, Symantec, TCS,


to list a particular line in the file

5 Answers  


How does pipe () work?

0 Answers  


What command is used to replace the existing string with some other?

8 Answers   TCS,


How do you find out all processes that are currently running in UNIX OS?

10 Answers  


what is the difference between pipe(|) and tee command..

3 Answers   Cap Gemini, Rolta,


how will u execute a file in unix

8 Answers   QA,


Categories