Home > Back-end >  How to cd into a folder without name created with ALT 255 in linux terminal
How to cd into a folder without name created with ALT 255 in linux terminal

Time:12-28

I tried different variants to enter with cd in the directory created with ALT 255 with the terminal in linux. one of the variants is cd "\ \" but it doesn't work. I also tried ASCII but it didn't work (cd " "). I don't know how to access that directory, does anyone know please?

CodePudding user response:

I suggest with bash:

# convert 255 to ff and then to its ascii character
printf -v foo "\x$(printf %x 255)"
cd "$foo"

CodePudding user response:

Use * in an array

cd "/to/path/with/problem/folder"
arr=(*) # create an array
echo "${arr[@]}" # check problem_folder index
cd "${arr[problem_folder_index]}" # cd to problem_folder

CodePudding user response:

You don't want to do that. You have now done something wrong, and you probably should clean that up. We can spend hours trying to explain how to get the right directory name, with hexdump -C or the likes, but in the end it is not something you are going to use in the real world.

Any way, if you really still want to cd to it, then you should use the correct directory-name. That would be alt 255. So, cd "alt255" should work (where alt255 should obviously be replaced with the alt 255 sequence that you used to create).

Or, in the shell:

for d in * ; do
    echo -n "DIR -$d- (y/n) "
    read a
    if [ "$a" = "y" ] ; then
        cd "$d"
    fi
done

(not as script, but directly on the prompt).

But, instead of cd you should either rm or mv.

Oh, and there is no folder without name; the name just consists of a character that is not printed.

  •  Tags:  
  • bash
  • Related