Basic bash script question
I have 4 folders in /Audio named:
Albums Compilations Singles & EPs Audio Books I'm looking for a bit of bash script that can create an files from these using the command something like: touch ${DIRS[index]}.txt Can anyone help? Kev |
Code:
for x in /Audio/* Code:
for x in /Audio/*; do test -d "$x" && touch "$x.txt"; done ...is that what you were asking? |
Thanks,
That's close, but not quite it. I'm looking to put the values onto an array in such a way as the can be used many times. Also in such a way that when I use: touch ${DIRS[index]}.txt when the array entry is "Singles & EPs" I get "Singles & EPs.txt" instead of: Singles.txt &.txt EPs.txt That's what I currently get. Thanks for the help. Kev |
Code:
i=0 Because of the spaces in some of your directory names, you'll need to reference the array elements from within quotes like: touch "${DIRS[index]}.txt" to keep bash from splitting the array element at its spaces. If this still isn't what you're asking for, maybe you could post your current code? |
All times are GMT -5. The time now is 05:50 PM. |