AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
 View Only
  • 1.  rm a file with name "- - exclude"

    Posted Thu July 01, 2010 03:03 AM

    Originally posted by: omnitivo


    Hi there,

    I a problem deleting a file :-). This is the output of "ls -all"
    #ls -all
    total 3450304
    -rw-r--r-- 1 root system 1656426496 Jun 30 10:40 --exclude
    drwxr-xr-x 14 sys sys 4096 Jun 30 10:38 .
    drwxr-xr-x 29 root system 1536 Apr 26 13:59 ..
    drwxr-xr-x 10 root sys 256 Apr 30 08:32 bin
    drwx------ 2 root sys 4096 Apr 01 2003 depot
    drwxr-xr-x 3 root sys 256 Mar 25 2003 include

    I tryed as root:
    #rm "--exclude"
    rm: Not a recognized flag: -
    Usage: rm -firRe -- File...

    #rm *exclude
    rm: Not a recognized flag: -
    Usage: rm -firRe -- File...

    My system:
    AIX 5300-10-01-0921
    any suggestions?
    #AIX-Forum


  • 2.  Re: rm a file with name "- - exclude"

    Posted Thu July 01, 2010 03:13 AM

    Originally posted by: omnitivo


    The problem is resolved. Here is the answer:

    By preceding the filename (-junkfile) with the pathname (./), you are able to hide the '-' character that starts the filename.

    rm ./"--exclude"
    #AIX-Forum


  • 3.  Re: rm a file with name "- - exclude"

    Posted Thu July 01, 2010 04:20 AM

    Originally posted by: esv


    You can use -- (double dash) to signal the end of options and the command will interpret the next - as part of the command arguments,, i.e/
    touch -- --exclude

    will create a file named --exclude.

    or: grep -- --exclude someotherfile ; will search for --exclude in someotherfile

    hence:

    rm -- --exclude; would have deleted your file.
    regards,
    esv.
    #AIX-Forum