Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UNIX Command Question- How do I just extract line 'X'
#1
Like just extract line 1?
I would think it'd be something like
grep -l 1 or something..
Reply
#2
If you want to do something like that, take a look at the man info for the 'more' or 'less' commands. That might be the appropriate tool for a simple job like that.


HTH
hwystar
Reply
#3
Sweet, thanks yet again hwystar.
Reply
#4
You got over the smashed finger fast enough. Or are you typing with your toes?
Reply
#5
How about combining both 'head' and 'tail'?

To extract the 100th line

head -n 100 thefilename.txt | tail -n 1

Reply
#6
HEAD(1) BSD General Commands Manual HEAD(1)

NAME
head -- display first lines of a file

SYNOPSIS
head [-n count] [file ...]

DESCRIPTION
This filter displays the first count lines of each of the specified
files, or of the standard input if no files are specified. If count is
omitted it defaults to 10.

If more than a single file is specified, each file is preceded by a
header consisting of the string ``==> XXX <=='' where ``XXX'' is the name
of the file.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)