- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Print a specific line of a large text ascii file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2002 08:18 PM
тАО07-18-2002 08:18 PM
Print a specific line of a large text ascii file
Is there any QUICK method in command line to print a specific line of a large ascii file (over 4M rows) ?
Regards,
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2002 08:22 PM
тАО07-18-2002 08:22 PM
Re: Print a specific line of a large text ascii file
1) With the line number:
# cat -n $FILE | cut -c5- | grep "^$LINENO "
2) Without the line number but with the specific contents:
# grep $PATTERN $FILE
To identify the line number after from the grep:
# grep -n $PATTERN $FILE
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2002 08:25 PM
тАО07-18-2002 08:25 PM
Re: Print a specific line of a large text ascii file
1) With the line number, you can also do this:
# head -$LINENO $FILE | tail -1
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2002 12:01 AM
тАО07-19-2002 12:01 AM
Re: Print a specific line of a large text ascii file
sed -n '1325p' /your/large/file
e.g. (with a not really big file)
# cat -n /etc/services |sed -n '123p'
123 hacl-hb 5300/tcp # High Availability (HA) Cluster he
artbeat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2002 12:04 AM
тАО07-19-2002 12:04 AM
Re: Print a specific line of a large text ascii file
# perl -ne 'print if $.==123' /etc/services
hacl-hb 5300/tcp # High Availability (HA) Cluster heartbeat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2002 12:14 AM
тАО07-19-2002 12:14 AM
Re: Print a specific line of a large text ascii file
if like the "old beasts".... Here is a solution with awk:
awk 'NR=1234, NR=1234' input_file
This will only print the line with number 1234.
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2002 12:35 AM
тАО07-19-2002 12:35 AM
Re: Print a specific line of a large text ascii file
more +/pattern file #Starts 2 lines above search string
more +linenumber file #Starts 2 lines above desired linenumber
See for more details/options --> man more
BB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2002 01:01 AM
тАО07-19-2002 01:01 AM
Re: Print a specific line of a large text ascii file
if you need to print only one line with a specific pattern in it:
awk '/your_pattern/, /your_pattern/' input_file
Or what exactly do you want?
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2002 01:02 AM
тАО07-19-2002 01:02 AM
Re: Print a specific line of a large text ascii file
don't forget another infamous beast:
$ echo "100p"|ed - my_file
Best regards
Juan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2002 06:36 AM
тАО07-19-2002 06:36 AM
Re: Print a specific line of a large text ascii file
I noticed no one got the bunny, is there something else you are looking for?
live free or die
harry