Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 07-07-2004, 07:28 PM   #1
Registered: Nov 2003
Location: Ohio
Distribution: Debian Unstable
Posts: 460

Rep: Reputation: 30
how to enumerate first line of text file to standard output?

hi, i need to parse only the first line of a text file, and i'm trying to come up with a bash script that will first of all enumerate only the first line to the user. i'm trying to use awk to do this, but i can't figure out what i need to do to get it to recognize a new line as the field separator. this is what i have so far:

awk -F\n '{print $1}' text.txt
the \n doesn't seem to work as i would expect (the full text in the file still gets listed). what is the best way to do this? thanks for any thoughts.

Last edited by zero79; 07-07-2004 at 07:30 PM.
Old 07-07-2004, 07:37 PM   #2
Registered: Nov 2003
Location: Ohio
Distribution: Debian Unstable
Posts: 460

Original Poster
Rep: Reputation: 30
5 minutes of digging and i answer my own question...hehe

head -1 text.txt


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ text file line by line/each line to string/array Dimitris Programming 15 03-11-2008 09:22 AM
sending data to standard out and to a text file at the same time. liguorir Linux - Software 1 08-23-2005 01:14 PM
How do I forward standard and error output into same file? ivj Linux - Software 5 07-19-2005 09:30 PM
Command to output file content line by line aznluvsmc Programming 2 09-12-2004 08:45 PM
How to redirect standard output of piped command to log file andrewstr Linux - General 10 02-04-2004 03:07 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:57 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration