Get selected line for Text File
-
- Battalion Quarter Master Havaldaar
- Posts: 207
- Joined: Sat Aug 09, 2003 5:00 pm
- Location: Karachi
- Contact:
Get selected line for Text File
I want to get select line from a text file, which linux command will work for it? means I want to get line 1-10 from abc.txt
-
- Battalion Quarter Master Havaldaar
- Posts: 207
- Joined: Sat Aug 09, 2003 5:00 pm
- Location: Karachi
- Contact:
Get selected line for Text File
And what I do if I need line from 20-30 ? I think "head" will not work for it.
-
- Site Admin
- Posts: 5132
- Joined: Fri May 02, 2003 10:24 am
- Location: Karachi
- Contact:
Re: Get selected line for Text File
Dear shakirz1,
Salam,
# tail -f filename
Best Regards.
Salam,
head + tail will workshakirz1 wrote:And what I do if I need line from 20-30 ? I think "head" will not work for it.
# tail -f filename
Best Regards.
Farrukh Ahmed
-
- Battalion Quarter Master Havaldaar
- Posts: 221
- Joined: Wed Aug 07, 2002 3:02 pm
- Location: Rawalpindi
awk to the rescue.
Assalam-O-Alaekum!
You can use awk for the purpose. Here is the command to solve your problem.
awk 'NR>10 && NR<21 {print}' abc.txt
Obviously, you can change the no.s 10 and 21 to select any range.
Regards.
You can use awk for the purpose. Here is the command to solve your problem.
awk 'NR>10 && NR<21 {print}' abc.txt
Obviously, you can change the no.s 10 and 21 to select any range.
Regards.
a10n3 s7r1k3r
Re: awk to the rescue.
finally! a sane post.s7r1k3r wrote:You can use awk for the purpose.