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

Why we are using UNIX OS when we are doing the testing in our application?

5 Answers   IBM,


Is grep faster than awk?

0 Answers  


Is command prompt unix?

0 Answers  


What command is used to switching between users in unix?

0 Answers  


How do you create a file in UNIX

36 Answers   Accenture, EMG, Nokia, QA, TD,






What is the difference between cat and more command?

0 Answers  


What is “chmod” command?

0 Answers  


Explain ‘system calls’ with respect to unix commands?

0 Answers  


How can we "forked" process in UNIX? How then recognize in any of the branches we?

2 Answers   NIIT,


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

3 Answers   Cap Gemini, Rolta,


What is the difference between awk and grep?

0 Answers  


to list a particular line in the file

5 Answers  


Categories