If you have a 'file' variable containing a whole path the a file, how do I get just its filename?
How does one iterate through space-separated strings in a big string? (I suspect this uses 'split' to create an array of strings)
What is a good bash scripting reference? http://justfuckinggoogleit.com/ is not the answer I'm looking for.
How does one iterate through space-separated strings in a big string? (I suspect this uses 'split' to create an array of strings)
What is a good bash scripting reference? http://justfuckinggoogleit.com/ is not the answer I'm looking for.
(no subject)
Date: 2006-10-14 12:20 am (UTC)(no subject)
Date: 2006-10-14 12:42 am (UTC)For (ba)sh, the 'for' command does what you want:
for x in $foo ; do mv $x `basename $x`/mainfile ; done
or whatever.
All my scripting I learned from man pages and looking at other sh scripts.
(no subject)
Date: 2006-10-14 02:52 am (UTC)(no subject)
Date: 2006-10-14 07:29 am (UTC)May your work become play
Date: 2006-10-15 07:00 am (UTC)/home/greg/2print/fuego2006-receipt.pdf
$ echo ${f##*/}
fuego2006-receipt.pdf
$ man bash
/## <--- type this literally followed by enter
Man pages are optimized for quick reference and refreshing of what you already know.
Info pages are (supposedly) optimized for both learning and reference.
Info pages are more casually browsable:
$ info bash
(or from emacs, [Control-H I], select bash documentation)
concept-index -> parameter expansion
or read Advanced Bash-Scripting Guide
and so on. Bash is fairly close to the other major shells. The solution I gave you will
work identically with either sh or ksh and, as the doc'n shows, is part of a more general
system.
Have fun,
_Greg