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 use of finger command?

0 Answers  


What is the command to check ports active in UNIX?

4 Answers   Accenture, IBM,


How do I use grep to search for a file?

0 Answers  


what is the advaantage of each user having its own copy of the shell?

2 Answers   Infosys,


can we use cat command as an editor ..???

12 Answers   TCS,






how many types of file in unix?

34 Answers   MNC, TCS,


what is the difference between KILL and KILL -9?

5 Answers   Informatica, Nutanix,


in UNIX,How do you check for processes started by particular user suppose the user name is 'suresh'?

6 Answers  


How do you copy a directory with many files and folders into another directory?

2 Answers  


what is the command to list all files in a directory, including the hidden files in UNIX ?

9 Answers   CTS,


What is pipe command in unix?

0 Answers  


How do you create a file in UNIX

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


Categories