mv won't accept my filename, so I can't touch it... (echo, tr and more too)
user@machine:$ mv "-GCPD-.png" file.png
mv: invalid option -- G Try `mv --help' for more information. user@machine:$ mv '-GCPD-.png' file.png mv: invalid option -- G Try `mv --help' for more information. user@machine:$ mv \-GCPD\-.png file.png mv: invalid option -- G Try `mv --help' for more information. user@machine:$ mv "\-GCPD\-.png" file.png mv: cannot stat `\\-GCPD\\-.png': No such file or directory user@machine:$ mv '\-GCPD\-.png' file.png mv: cannot stat `\\-GCPD\\-.png': No such file or directory user@machine:$ mv *.png file.png mv: invalid option -- G Try `mv --help' for more information. mv --help gives me crap for help However this bad manual page reminds me of a similiar problem I had with cut: <strike> A year ago? I wanted to cut a text file into fields on a ' ', and there's no way to specify that.... The man pages suck, and the info pages are just as bad. I figured out a work-around by transforming a ' ' into a \tab, but that's hack, and won't work on all files. From the cut man page: -d, --delimiter=DELIM use DELIM instead of TAB for field delimiter info coreutils cut : `-d INPUT_DELIM_BYTE' `--delimiter=INPUT_DELIM_BYTE' (which has actually changed, IIRC, they had something else after the =, which was undefined anywhere in the documentation) </strike> Yeah, it's working now, same commands... Whatever. I also tried setting it as hex? (\0xxx) which I've used successfully in other scripts, but I don't have notes on what space is in that format (just tab, return, and slashes and quote marks). And echo doesn't return the same values as transform for those - even if I could get cut to accept them... So I can't figure out what the numbers should be (reliably) user@machine:$ cat file line1 line2 user@machine$ cat file | tr '\0120' "###" line1#line2#user@machine:$ echo -e "\0120" P Leading me onwards, I also (on a Solaris box) used to have access to a tr which would do more than 1-for-1 swapping of stuff. If you said tr 'a' 'abba' it would insert abba for every instance of 'a'. It would also do: tr 'abba' 'acca' transformations. This too, has been lost (probably I need to move up to awk or sed or something, but that was nice and easy for simple stuff). |
In the mv man page it says that using -- will terminate your option list. That means that anything like '-G' after that won't be treated as an option. So the following will work:
Code:
mv -- -GPCD-.png file.png |
that worked... but...
Thanks.
That worked, but it's not listed in my man pages, nor in my info pages for mv. Unless I'm completely blind?? MV(1) User Commands MV(1) NAME mv - move (rename) files SYNOPSIS mv [OPTION]... SOURCE DEST mv [OPTION]... SOURCE... DIRECTORY mv [OPTION]... --target-directory=DIRECTORY SOURCE... DESCRIPTION Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY. Mandatory arguments to long options are mandatory for short options too. --backup[=CONTROL] make a backup of each existing destination file -b like --backup but does not accept an argument -f, --force do not prompt before overwriting (equivalent to --reply=yes) -i, --interactive prompt before overwrite (equivalent to --reply=query) --reply={yes,no,query} specify how to handle the prompt about an existing destination file --strip-trailing-slashes remove any trailing slashes from each SOURCE argument -S, --suffix=SUFFIX override the usual backup suffix --target-directory=DIRECTORY move all SOURCE arguments into DIRECTORY -u, --update move only when the SOURCE file is newer than the destination file or when the destination file is missing -v, --verbose explain what is being done --help display this help and exit --version output version information and exit The backup suffix is ‘~’, unless set with --suffix or SIM‐ PLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through the VERSION_CONTROL environment variable. Here are the values: none, off never make backups (even if --backup is given) numbered, t make numbered backups existing, nil numbered if numbered backups exist, simple otherwise simple, never always make simple backups AUTHOR Written by Mike Parker, David MacKenzie, and Jim Meyering. REPORTING BUGS Report bugs to <bug-coreutils@gnu.org>. COPYRIGHT Copyright © 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. SEE ALSO The full documentation for mv is maintained as a Texinfo manual. If the info and mv programs are properly installed at your site, the com‐ mand info coreutils mv should give you access to the complete manual. mv (coreutils) 5.2.1 March 2005 MV(1) File: coreutils.info, Node: mv invocation, Next: rm invocation, Prev: instal\l invocation, Up: Basic operations 11.4 `mv': Move (rename) files ============================== `mv' moves or renames files (or directories). Synopsis: mv [OPTION]... SOURCE DEST mv [OPTION]... SOURCE... DIRECTORY If the last argument names an existing directory, `mv' moves each other given file into a file with the same name in that directory. Otherwise, if only two files are given, it renames the first as the second. It is an error if the last argument is not a directory and more than two files are given. `mv' can move any type of file from one filesystem to another. Prior to version `4.0' of the fileutils, `mv' could move only regular files between filesystems. For example, now `mv' can move an entire directory hierarchy including special device files from one partition to another. It first uses some of the same code that's used by `cp -a' to copy the requested directories and files, then (assuming the copy succeeded) it removes the originals. If the copy fails, then the part that was copied to the destination partition is removed. If you were to copy three directories from one partition to another and the copy of the first directory succeeded, but the second didn't, the first would be left on the destination partition and the second and third would be left on the original partition. If a destination file exists but is normally unwritable, standard input is a terminal, and the `-f' or `--force' option is not given, `mv' prompts the user for whether to replace the file. (You might own the file, or have write permission on its directory.) If the response does not begin with `y' or `Y', the file is skipped. _Warning_: If you try to move a symlink that points to a directory, and you specify the symlink with a trailing slash, then `mv' doesn't move the symlink but instead moves the directory referenced by the symlink. *Note Trailing slashes::. The program accepts the following options. Also see *Note Common options::. `-b' `--backup[=METHOD]' *Note Backup options::. Make a backup of each file that would otherwise be overwritten or removed. `-f' `--force' Do not prompt the user before removing a destination file. `-i' `--interactive' Prompt whether to overwrite each existing destination file, regardless of its permissions. If the response does not begin with `y' or `Y', the file is skipped. `--reply[=HOW]' Specifying `--reply=yes' is equivalent to using `--force'. Specify `--reply=no' to make `mv' act as if `no' were given as a response to every prompt about a destination file. Specify `--reply=query' to make `mv' prompt the user about each existing destination file. `-u' `--update' Do not move a non-directory that has an existing destination with the same or newer modification time. `-v' `--verbose' Print the name of each file before moving it. `--strip-trailing-slashes' Remove any trailing slashes from each SOURCE argument. *Note Trailing slashes::. `-S SUFFIX' `--suffix=SUFFIX' Append SUFFIX to each backup file made with `-b'. *Note Backup options::. `--target-directory=DIRECTORY' Specify the destination DIRECTORY. *Note Target directory::. `-V METHOD' `--version-control=METHOD' Change the type of backups made with `-b'. The METHOD argument can be `none' (or `off'), `numbered' (or `t'), `existing' (or `nil'), or `never' (or `simple'). *Note Backup options::. An exit status of zero indicates success, and a nonzero value indicates failure. |
Just as well I didn't make some stupid comment about reading the man pages properly ;) In the Slackware docs it's listed under POSIX options (and GNU options), not the regular options - so it may be that Ubuntu haven't updated their docs yet.
Makes it like trying to drive a car without being told there's such a thing as gears... You can still move, just not the way you want to. Yes, that's a terrible joke, but it's Friday afternoon here and I'm going home before too much longer :) |
All times are GMT -5. The time now is 06:33 PM. |