LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Command line question (https://www.linuxquestions.org/questions/linux-newbie-8/command-line-question-4175489169/)

hhoyt 12-25-2013 07:53 PM

Command line question
 
My apologies on the title, not sure how to phrase, which is probably why I cannot find with Google.

I prefer to run from the cmd line but have a problem on download of a file that exists already. It gets turned into file.ext(1) or suffixed to number of copies- which is my problem, I do not understand how to handle these suffixed files ???
How do I manipulate from the command line ???
Driving me nuts. Mv seems to complain about directory and I think I read that command line 'rename' is really a utility. Certainly file manager has no trouble changing something like file.ext(2) into file.ext but then cmd line d/n recognize file.ext

Peppermint 3 kernel 3.12.6
==========>>>
~/Downloadsls pvrc.org*
pvrc.org (2) pvrc.org-Dec-2013.gz

~/Downloadsmv pvrc.org* pvrc.org
mv: target `pvrc.org' is not a directory

~/Downloadsmv pvrc.org* ./pvrc.org
mv: target `./pvrc.org' is not a directory

~/Downloadsrename pvrc.org* pvrc.org
Bareword "pvrc" not allowed while "strict subs" in use at (eval 1) line 1.

I am sure there is a good writeup on my problem, but I am missing how to search on it.

Thanks, Howie

syg00 12-25-2013 08:31 PM

Use "mv" with the full filename with back-slashes to escape the blank and (both) parentheses (i.e. don't use the aster).

Shadow_7 12-25-2013 08:41 PM

Depending on the distro, mv may not overwrite "existing" files with a matching destination name. Rename is mildly more useful when names contain characters not on a qwerty keyboard. But they basically do the same task. You could cp (copy) and cmp (compare) and rm (delete) the old name and location. Depending on how paranoid you are with your data. The mv option trumps cp in many cases because it preserves the original date/time stamp of the file.

The behavior you describe seems to be the default behavior of web browsers. You could just copy the link and wget the file. Using wget -c lets you continue if wasn't fully downloaded (must be an option serverside / not local). Or wget -i to get from a list of links in a file that follows -i. But in general web browsers do the download of already downloaded stuff and add a postfix on the filename. Even though the same file without the postfix already exists and matches it byte for byte.

hhoyt 12-25-2013 08:47 PM

I must be doing it wrong:

~/Downloadsmv pvrc.org\(\2\)\ pvrc.org
mv: missing destination file operand after `pvrc.org(2) pvrc.org'


~/Downloadsmv -f pvrc.org\(\2\)\ pvrc.org
mv: missing destination file operand after `pvrc.org(2) pvrc.org'

Tks, Howie

hhoyt 12-25-2013 08:54 PM

~/Downloadsmv pvrc.org \(\2\)\ pvrc.org
mv: cannot stat `pvrc.org': No such file or directory

nd7rmn8 12-25-2013 09:11 PM

you are getting closer, try either of these.
Code:

mv pvrc.org\ \(2\) pvrc.org
mv 'pvrc.org (2)' pvrc.org


hhoyt 12-26-2013 08:28 AM

mv 'pvrc.org (2)' pvrc.org
is a simple solution.

Thanks !

Howie

Shadow_7 12-26-2013 04:08 PM

mv pvrc.org\(\2\)\ pvrc.org

The trailing \ on the originating filename is probably what gotcha on your previous attempts. It would escape the space between input and output names and make it all one filename, which it can't find. And of course nothing to move it to since the concatenated input omits the output parameter.

If you need a gui option, nautilus (or whatever it goes by these days) lets you do the traditional click wait click to rename a file. Or right mouse -> rename. When all else fails, like unicode / cyrillic characters or filenames with tab characters in them. Which can be annoying to deal with on some [x]terms.


All times are GMT -5. The time now is 06:24 AM.