f76
December 18th, 2006, 08:31 PM
Playing around with gentoo file manager http://en.wikipedia.org/wiki/Gentoo_file_manager
i felt the need for a script to join multipart files. But u could use it just as well from Nautilus i guess.
Now that i have got mine working i thought i would post it here to see if you guys can help me w some pointers..
How would you make the script safer/faster?
And how would you solve the problem...
It might sound stupid to ask about a problem i have solved but i thought i could learn from some feedback.
#!/bin/bash
echo "infile:"
echo "$1"
echo ""
# first sed makes sure the filename ends in .001 and replaces it w .0??
# second sed replaces spaces w backslashes
inname=$(echo "$1"|sed -e 's/\.001$/\.0\?\?/'|sed -e 's/\ /\\\ /g')
#echo $inname
# first sed makes sure the filename ends in .001 and replaces it w ""
# second sed replaces spaces w backslashes
outname=$(echo "$1"|sed -e s/\.001$//|sed -e 's/\ /\\\ /g')
#echo $outname
wholecommand=$(echo "cat $inname > $outname")
echo "command:"
echo $wholecommand
#it took some time to figure out this one:
eval $wholecommand
#to keep "gnome-terminal -w" open
echo "******* Press <Enter> to continue ********"
read NAME
echo "$NAME!"
i felt the need for a script to join multipart files. But u could use it just as well from Nautilus i guess.
Now that i have got mine working i thought i would post it here to see if you guys can help me w some pointers..
How would you make the script safer/faster?
And how would you solve the problem...
It might sound stupid to ask about a problem i have solved but i thought i could learn from some feedback.
#!/bin/bash
echo "infile:"
echo "$1"
echo ""
# first sed makes sure the filename ends in .001 and replaces it w .0??
# second sed replaces spaces w backslashes
inname=$(echo "$1"|sed -e 's/\.001$/\.0\?\?/'|sed -e 's/\ /\\\ /g')
#echo $inname
# first sed makes sure the filename ends in .001 and replaces it w ""
# second sed replaces spaces w backslashes
outname=$(echo "$1"|sed -e s/\.001$//|sed -e 's/\ /\\\ /g')
#echo $outname
wholecommand=$(echo "cat $inname > $outname")
echo "command:"
echo $wholecommand
#it took some time to figure out this one:
eval $wholecommand
#to keep "gnome-terminal -w" open
echo "******* Press <Enter> to continue ********"
read NAME
echo "$NAME!"