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

write grep commands to select the lines that have exactly two characters

8 Answers   PSI Data Systems,


their is a file1,file2 and i want to append file1 data to file2?

9 Answers   IBM,


How to identify whether a file is normal file or directory?

3 Answers  


Is grep faster than awk?

0 Answers  


How to replace the exact word in vi editor?? suppose a file contains words like amaze,amazed,amazement in some of the line.But i want to replace only 'amaze' with delight but don't wanna replace amazed or amazement. thanks

6 Answers   Polaris, Tech Mahindra,






What does awk stand for?

0 Answers  


What is awk good for?

0 Answers  


what do you understand by 'building block primitive'?

3 Answers   Infosys,


Is there any method to erase all files in the current directory, along with its all sub-directories, by using only one command?

0 Answers  


how to delete entire records in unix ?

13 Answers   Cap Gemini,


What is the difference between Shell Programming and Shell scripting?

10 Answers   HCL, TCS, Wipro,


How does shebang work?

0 Answers  


Categories