Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Rename a folder called '\n'

  • 11-07-2008 12:35pm
    #1
    Registered Users, Registered Users 2 Posts: 2,032 ✭✭✭


    For some reason and I don't know how, but a user has renamed a folder to '\n'.

    So when you ls -l it just has a '?', but when you do an ls -lb it comes up as '\n'.

    Any ideas how I could rename this folder? I've tried

    mv '\n' newfoldername

    Any help appreciated.


Comments

  • Registered Users, Registered Users 2 Posts: 2,032 ✭✭✭colm_c


    Tried those

    Getting an error:
    mv: cannot stat `n': No such file or directory
    mv: cannot stat `\\n': No such file or directory


  • Closed Accounts Posts: 66 ✭✭Danimalito


    hmm.. you can probably do something like this (assuming bash shell)

    % for i in *; do printf "rename $(ls -db $i) ? [y/N] "; read a; [ "$a" == "y" ] && mv -- $i targetdir;done


  • Registered Users, Registered Users 2 Posts: 2,032 ✭✭✭colm_c


    Not working either.

    I might have to look at a backup and restore from that.


  • Closed Accounts Posts: 12 Aquafresh


    When you say: "the folder name is '\n'"
    I think what you really mean is: "the folder name is $THE_NEWLINE_CHAR" (if you get me)

    '\n' is just an escape sequence used in C etc. for inserting a newline character (line feed, 0x0a) in a string. i.e. the string
    "asf\n\nasfhkasf\n" in actuality (i.e. if viewed in a debugger etc.) is:
    "asf$(0x0a)$(0x0a)nasfhkasf$(0x0a)

    so basically your shell is interpreting the directory name (0x0a) as '\n' and printing that for you. To delete/rename/remove the dir you just need to say 'mv $(0x0a) foo'

    In zsh (emacs mode) I can do this by saying:
    mv 'C-q
    ' foo

    (this prints like:
    [root@bbbox]/root# mv '
    quote> ' foo
    )



    in bash:
    mv 'C-vC-j' foo

    (this prints like:
    [root@bbbox ~]# mv '
    > ' foo
    )

    C-q means press control and q, C-v means press control and v.

    Hope this helps


  • Registered Users, Registered Users 2 Posts: 2,032 ✭✭✭colm_c


    Aquafresh wrote: »
    When you say: "the folder name is '\n'"
    I think what you really mean is: "the folder name is $THE_NEWLINE_CHAR" (if you get me)

    '\n' is just an escape sequence used in C etc. for inserting a newline character (line feed, 0x0a) in a string. i.e. the string
    "asf\n\nasfhkasf\n" in actuality (i.e. if viewed in a debugger etc.) is:
    "asf$(0x0a)$(0x0a)nasfhkasf$(0x0a)

    so basically your shell is interpreting the directory name (0x0a) as '\n' and printing that for you. To delete/rename/remove the dir you just need to say 'mv $(0x0a) foo'

    In zsh (emacs mode) I can do this by saying:
    mv 'C-q
    ' foo

    (this prints like:
    [root@bbbox]/root# mv '
    quote> ' foo
    )



    in bash:
    mv 'C-vC-j' foo

    (this prints like:
    [root@bbbox ~]# mv '
    > ' foo
    )

    C-q means press control and q, C-v means press control and v.

    Hope this helps

    You sir are a legend.

    Worked a treat.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    impressed tbh.


  • Registered Users, Registered Users 2 Posts: 1,562 ✭✭✭cance


    Khannie wrote: »
    impressed tbh.

    agreed, and that he's been registered for 10 years and only posted 8 times... that is legendary lurking.


  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    cance wrote: »
    that is legendary lurking.

    HAHAHA. :D


Advertisement