[Leaplist] Re: LUNA: command line question ....

William A. Mahaffey III wam at hiwaay.net
Sat Feb 14 18:39:00 EST 2009


Ryan Waldron wrote:
> On Sat, 14 Feb 2009, William A. Mahaffey III wrote:
>
>> .... is there a way intrinsic to tcsh, bash, or perhaps using awk, to 
>> 'mask' off the 1st n (or last n for that matter) elements of a long 
>> pathname (i.e. go from '/some/darn/long/idiot/moron/path' to either 
>> '/some/darn/long' or /long/idiot/moron/path', for example) ? I have 
>> RTFM a fair amount & it is eluding me .... TIA ....
>
> A simple way is to use cut:
>
> $ echo "/some/really/long/path/that/shouldnt/be/this/long.txt" | cut 
> -f7- -d/
> shouldnt/be/this/long.txt
>
> $ echo "/some/really/long/path/that/shouldnt/be/this/long.txt" |cut 
> -f-6 -d/
> /some/really/long/path/that
>
> Less impressive than sed, but still...
>
> -- 
> Ryan Waldron    |||   http://www.erebor.com    |||    rew at erebor.com
>
> "The web goes ever, ever on, down from the site where it began..."
>
> ----
> LUNA-LIST help:                  luna-list-help at luna.huntsville.al.us
> To unsubscribe:           luna-list-unsubscribe at luna.huntsville.al.us
> To email the list keeper:                        dgregg at knology.net 
> LUNA-LIST Web Site:   <URL:http://luna.huntsville.al.us>
>


Oooooooo, another nice one, more terse than sed, a bit easier to 
understand. I hate it when my ignorance/forgetfulness are *SO* obvious 
:-) .... Thanks.


-- 

	William A. Mahaffey III

 ----------------------------------------------------------------------

	"The M1 Garand is without doubt the finest implement of war
	 ever devised by man."
                           -- Gen. George S. Patton Jr.


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the Leaplist mailing list