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

Re: bash: how to split a $var ?



On Mon, Jun 23, 2003 at 11:25:37AM +0100, David selby wrote:
> In bash how can I split a string eg ...
> 
> var1=0624todaysfile
> 
> I want var2 to equal the first 4 digits, ie 0624
> My first instinct was cut but this is for files only, head & tail are of 
> no use ...

echo $var1 |cut -c 5-${#var1}

-- 
hugh



Reply to: