[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Bash script question
Geoffrey wrote:
> Bob Kruger wrote:
>
>>All;
>>
>>I need to parse some simple text files. I would like to do this in
>>the BASH shell and not have to invoke Perl, AWK, etc. I did the same
>>a couple of years ago, but lost the code.
>>
>>If I have a text file that has, for example, 6 lines, and I want to
>>parse field in the 4th line, what can I run from the BASH shell to
>>print out only the 4th line?
>
>
> sed -n '4p' text_file
>
> tail -4 text_file|line
>
> head -n4 text_file|tail -1
>
> awk '{if (NR == 4) {print; exit}}' text_file
Here's a another, but we are getting a bit esoteric...
ed -s <<- END text_file
4p
END
--
Until later, Geoffrey