Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Renaming a file that starts with "-"

$
0
0
Hi

I am downloading some files from the Internet. They are from different sources and they are all called
Code:

-.txt
that is: a dash "-" followed by a dot "." and then the file extension.
So i wrote a small script that hoped will downloads the first file and then rename them once they are completely downloaded. Here is the script I wrote:
Code:

#!/bin/sh
for i in `seq 1 1 30`
do
wget url
mv ./-.txt $i.txt
done

but what I get is that the script (above) downloads the first file "-.txt" and does not rename it to 1.txt as I wanted, and so keeps giving me the message that file "-.txt" has already been downloaded.

What is wrong in my script? (I have little experience with scripting in bash)

Thank you

Viewing all articles
Browse latest Browse all 16232

Trending Articles