mercredi 4 mars 2015

how to locate a name-not-specified file in bash? [on hold]


I have a bash like this to easily upload a file to my server:



FILE=../"$1"/1.txt
scp 1.txt remoteserver #upload the file to a remote server.


The $1 is for input directory and I have a lot of directories. But the txt file in all those directories are not all named "1.txt". What I can confirm is that each directory only contains one txt file.


How do I locate that file in this situation?


Update:


I tried to type FILE=../"$1"/1.txt


but when I check the file with:


if [ -f "$FILE" ]


I notice it's getting a false even when the file exist.


I figured out that:


$FILE is ../test/1.txt


"$FILE" is ../test/*.txt


So do I have to remove the pair of "?



Aucun commentaire:

Enregistrer un commentaire