Move file contents to another file with bash script (find, mimetype and cat)
Hi There :)
I get some files from my ftp and now I want to sort them. Some are images, some are text files which contain one link each. I want to sort the files with a while loop. Here is what I have done so far. Code:
#!/bin/bash The optimal solution would be, if the resulting textfile contains the filename and in the next line the link from the file. Maybe it's just a small thing I forgot...? |
I am not sure I follow the logic??
1. read -a Files -> this means read into the array Files - as find will return each item found, why would you want to read them into an array? 2. you refer to ${Files} throughout the loop -> again see above but this is not how you would refer to an array, should be something like ${Files[@]} 3. cat "${Files}" | sort >> temp.list - you mentioned that the files contain one link each (I look at this as saying only one line in each file) ... if this is the case there is nothing to sort?? So this should just be: Code:
cat "${Files}" >> temp.list 5. personally I would use a for loop with globbing and pass if the files are not the ones your looking for (again though ... that is just my thought on that one) Hope some of that helps |
All times are GMT -5. The time now is 05:24 PM. |