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

Which command is used to restrict incoming messages?

0 Answers  


Is it inbetween or in between?

0 Answers  


What is $0 bash?

0 Answers  


Write a command that will output the sorted contents of a file named in.txt and place the output in another file named out.txt, while at the same time excluding duplicate entries.

1 Answers  


What Command will remove a Directory in UNIX?

8 Answers   IBM,






What is grep and sed command?

1 Answers  


Assume that a file’s permissions give you read and write access. What operations can you perform on the file if it is in a directory which has “r”(read) only process? What operations can you perform on the file if it is in a directory which has “x”(execute) only access?

1 Answers  


What are the dos commands?

0 Answers  


What is time_t?

0 Answers  


How can you see the command line history?

0 Answers  


Name the general commands in using unix os for a beginner?

0 Answers  


who to change the duplex setting of network interface in command line

1 Answers  


Categories