[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: text editing



Hi Tsuyoshi,
I think you are talking about extracting the first field from a line of
output.
This is common. one tool that is easy to use is awk.
try:
ps -A
ps -A|awk '{print $1}'
ps -A|awk '{print $2}'
awk's default field seperator is the space characher.
so, $1 is the field before the 1st space and $2 is the field after the
1st space and before the 2nd.
there are tutorial for this online. try:

http://cs.hmc.edu/tech_docs/qref/awk.html

awk can do many things and people use it with other tools are not
availble becuase it is on all linux/unix/solaris machines.
The answer with awk: wc -l 1.txt|awk '{print $1}'

-K
On Sat, 2003-05-24 at 00:44, Tsuyoshi Takada wrote:
> Hi,
> 
> $ wc -l 1.txt
> returns
> " 150 1.txt"
> 
> I want to extract the lines count "100" as the following,
> 
> $ wc -l 1.txt | <some sommand>
> returns
> 100
> 
> grep -Po option can realize this but -Po options is supported after
> grep-2.5 and my system is grep-2.4.2.
> 
> Is there any other idea?
> 
> 
> -- 
> Tsuyoshi Takada <acroyear@gmx.ch>
-- 
Kevin Mark <kmark@pipeline.com>

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: