[Wylug-help] Shell scripting
Geoff Richards
qef at ungwe.org
Mon May 10 01:40:09 BST 2004
On Sun, May 09, 2004 at 10:23:34PM +0100, Nick Jeffery wrote:
> Hullo,
>
> I've a variable (from cat'ing a file) in a bash shell script. I'd
> like to get only the first 32 characters of the file/variable on their
> own..
>
> I've tried:
>
> foo=`echo ${bar:32}` but that doesn't seem to want to play ball.
>
> Anyone got an idea? Don't want to use regexps/perl/awk if at all
> possible.
How about this:
foo=`echo "$bar" | head --bytes=32`
--
--- Geoff Richards -------------><-------------- http://ungwe.org/ ---
"I tried to fling my shadow at the moon,
The while my blood leapt with a wordless song." -- Theodore Roethke
More information about the Wylug-help
mailing list