How to get desire line?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to get desire line?
# 1  
Old 12-03-2014
How to get desire line?

Hi Guys,

I am newbie here and greeting to all guys of unix forum, now I want to learn unix here.

I have query here, we have file where file has 20 line record, now i want display 10 to 15 line row record only, then how it possible.
# 2  
Old 12-03-2014
Hello Aditya321,

Welcome to forum, we hope you will enjoy learning new things here.
Following may help you in same.

Code:
awk 'NR>=10 && NR<=15' Input_file


Thanks,
R. Singh
# 3  
Old 12-03-2014
Code:
sed -n 10,15p file

# 4  
Old 12-03-2014
Thank you so much Ravinder & Scrutinizer.
# 5  
Old 12-03-2014
We can achieve this by head and tail command also.

Code:
head -n 15 file | tail -n 6

# 6  
Old 12-03-2014
how about

Code:
awk 'NR == 10, NR == 15 { print  $0 }' infile

you could use vi and then

Code:
:10,15w!/infile

or in perl

Code:
perl -ne 'print if 10..15' infile


Last edited by ritakadm; 12-03-2014 at 11:35 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. What is on Your Mind?

Where do I start as someone who desire to become skilled in UNIX and C?

Hi, for some time now I have been away. Things got so though I had to get a job. Whilst on the job i never felt free to do the thing i truly desired. Its like two masters trying to get my attention. One had to go for the other. To sum up i quit my job and i felt that was the best decision i ever... (4 Replies)
Discussion started by: split_func0
4 Replies

2. Hardware

HTC Desire S vs HTC Desire C - USB Android tethering problem

Hi gurus, I have problem with android usb tethering (usb0 interface). I tried two phones HTC Desire C and HTC Desire S. With Desire C everything works as expected, usb0 automatically goes up and gains IP address and tethering is working (output bellow) HTC Desire C: Nov 6 23:32:36 HP-PC... (0 Replies)
Discussion started by: wakatana
0 Replies

3. Shell Programming and Scripting

Users who desire to have their .profile executed must explicitly do so in the crontab entry. Why?

The .profile file should be read when the user logs in. So, there should be no need to execute .profile file again in a cron job (since the cron job is run after the user logs in). Doesn't the cron require login from the user. Then, from where does the cron execute? Please help!! (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

4. Shell Programming and Scripting

Desire structure for input file

Hello Unix gurus, I have a txt file with single columns with n no of rows.like below COLUMN1 ======= AAA BBB CCC DDD EEE FFF GGG HHH . . . NNN. (10 Replies)
Discussion started by: kanakaraju
10 Replies

5. Shell Programming and Scripting

Can't get DF output I desire

I currently have a shell script that creates Oracle databases configured the way we want them here. One part of it allows you to choose which file system to place the database files. This is the command which works. This produces a list of file systems from which to choose. I have been... (1 Reply)
Discussion started by: sewood
1 Replies

6. Shell Programming and Scripting

How to insert and delete any line after desire line

like i have file like abc 123 pqr bbbb ttttttttt t tttt ------------------ i want to insert "class" after pqr and t lines please suggest me. (4 Replies)
Discussion started by: RahulJoshi
4 Replies
Login or Register to Ask a Question