Using AWK...I need to print from column 4 to end

  • Follow


I have the follwoing output from my command on AIX.

cd0 Available 04-08-00 IDE DVD-ROM Drive

Now I need to print from column 4 to end.

0
Reply truejack (9) 6/13/2005 9:28:01 AM


truejack@indiainfo.com wrote:
> I have the follwoing output from my command on AIX.
> 
> cd0 Available 04-08-00 IDE DVD-ROM Drive
> 
> Now I need to print from column 4 to end.
> 

If you want to preserve white-space in the remaining fields and have a 
POSIX awk (e.g. gawk --posix) or gawk --re-interval):

awk 'sub(/^[[:space:]]*([^[:space:]]*[[:space:]]*){3}/,"")'

If you don't care about preserving white-space:

awk '{$1=$2=$3=""}1'

	Ed.
0
Reply Ed 6/13/2005 1:04:52 PM


truejack@indiainfo.com wrote:
> I have the follwoing output from my command on AIX.
> 
> cd0 Available 04-08-00 IDE DVD-ROM Drive
> 
> Now I need to print from column 4 to end.

1.  a='cd0 Available ...'
    echo ${a#???}

2.  sed 's/^...//'

-- 
William Park <opengeometry@yahoo.ca>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
	   http://home.eol.ca/~parkw/thinflash.html
0
Reply William 6/13/2005 2:43:19 PM


William Park wrote:
> truejack@indiainfo.com wrote:
> 
>>I have the follwoing output from my command on AIX.
>>
>>cd0 Available 04-08-00 IDE DVD-ROM Drive
>>
>>Now I need to print from column 4 to end.
> 
> 
> 1.  a='cd0 Available ...'
>     echo ${a#???}
> 
> 2.  sed 's/^...//'
> 

I thought by "column" the OP meant "field" rather than "character". If 
it's character then the awk solution is:

	awk '{sub(/.../,"")}1'

Regards,

	Ed.
0
Reply Ed 6/13/2005 2:57:14 PM


Ed Morton wrote:
> 
> 
> William Park wrote:
> 
>> truejack@indiainfo.com wrote:
>>
>>> I have the follwoing output from my command on AIX.
>>>
>>> cd0 Available 04-08-00 IDE DVD-ROM Drive
>>>
>>> Now I need to print from column 4 to end.
>>
>>
>>
>> 1.  a='cd0 Available ...'
>>     echo ${a#???}
>>
>> 2.  sed 's/^...//'
>>
> 
> I thought by "column" the OP meant "field" rather than "character". If 
> it's character then the awk solution is:
> 
>     awk '{sub(/.../,"")}1'
> 
> Regards,
> 
>     Ed.

Or:
awk '{print substr ($0, 4)}'

Bill Seivert

0
Reply Bill 6/22/2005 5:15:13 AM

4 Replies
267 Views

(page loaded in 0.077 seconds)

Similiar Articles:













7/22/2012 12:43:46 AM


Reply: