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

Revenge of bash



I need more help with another bash scripting issue to resolve. I have a
script that reads filenames into an array (DELTEXT in the example
below--I know it's not an array here, I've watered down the function so
I don't have to run the whole script each time (~15 minutes each
execution)) ...anyway... In the example below, I can strip the
".tar.bz2" from the filename with the awk command (does anyone know a
better way?), but it's really not very useful unless I can get it stored
in a variable. What I need to do ultimately is keep the old value in the
array (ie. 123456789.tar.bz2) and create a new variable on-the-fly with
the value 123456789.index. I can't figure out how to send the command
line output to a variable. Am I making this harder than it needs to be?
Attempts at redirection, complicated quoting schemes, rubbing my bash
and awk books together furiously, and sacrificing sleep to the Linux
gods have so far left me more bald. Thanks in advance.

clear
DELTEXT="123456789.tar.bz2"
DELITEM="echo $DELTEXT | awk -F. '{ print \$1 }'"
# debugging stuff
echo Step 1
echo $DELTEXT
echo
echo Step 2
eval $DELITEM