1836636 Members
1852 Online
110102 Solutions
New Discussion

cut help

 
SOLVED
Go to solution
M.Thomas
Frequent Advisor

cut help

i have the following lines from lpstat in a file i just need the name and ip or full name

remote to: ak01 on ak01.dsa.abc.com
remote to: HR51 on HR51

example

just need like this

ak01 ak01.dsa.abc.com

Please help

thomas
5 REPLIES 5
Paul Sperry
Honored Contributor

Re: cut help

more filename | awk '{print $3 $5}' > newfilename
M.Thomas
Frequent Advisor

Re: cut help

this does not print the space in between which is required

thomas
James R. Ferguson
Acclaimed Contributor

Re: cut help

Hi Thomas:

Directly (match and extract):

# lpstat -v|awk '/remote to:/ {print $3,$5}'

Regards!

...JRF...
TwoProc
Honored Contributor
Solution

Re: cut help

re: doesn't print the space:

more filename | awk '{print $3 " " $5}' > newfilename

That will fix it.
We are the people our parents warned us about --Jimmy Buffett
Peter Godron
Honored Contributor

Re: cut help

Hi,
as you asked for "cut help":
cut -d' ' -f3,5 filename