GNU Parallel is outputting hidden directories as follows using the --results parameter.

What command do I use on Ubuntu to change the all to directories so that they are no longer hidden. The directories are called:

'.\_ValidateAll.sh GL 170'/
'.\_ValidateAll.sh GL 190'/
'.\_ValidateAll.sh GL 220'/
'.\_ValidateAll.sh GL 355'/
'.\_ValidateAll.sh GL 357'/
'.\_ValidateAll.sh GL 359'/
'.\_ValidateAll.sh GL 361'/
'.\_ValidateAll.sh GL 363'/

enter image description here

Actually when I do a cat on the directory, I don't see the single quotes

vmdovs@ubuntu:/mnt/out/1$ cat 
GL170/                    .\_ValidateAll.sh GL 357/ .\_ValidateAll.sh GL 390/ .\_ValidateAll.sh GL 470/ .\_ValidateAll.sh GL 570/
rename.sh                 .\_ValidateAll.sh GL 359/ .\_ValidateAll.sh GL 400/ .\_ValidateAll.sh GL 480/ .\_ValidateAll.sh GL 572/
.\_ValidateAll.sh GL 190/ .\_ValidateAll.sh GL 361/ .\_ValidateAll.sh GL 410/ .\_ValidateAll.sh GL 500/ .\_ValidateAll.sh GL 574/
.\_ValidateAll.sh GL 220/ .\_ValidateAll.sh GL 363/ .\_ValidateAll.sh GL 420/ .\_ValidateAll.sh GL 530/ .\_ValidateAll.sh GL 590/
.\_ValidateAll.sh GL 355/ .\_ValidateAll.sh GL 368/ .\_ValidateAll.sh GL 440/ .\_ValidateAll.sh GL 540/ .\_ValidateAll.sh GL 710/

Also cd can access the directory as follows

cd .\\_ValidateAll.sh\ GL\ 190/
  • Could you verify the placement of the single quotes ' ... ' in your list of directory names? Are they literally there, or did you use them for clarification purposes? If possible, change that list to contain the output of ls -l instead, it may be easier to interpret (for a human, that is ... ;) ) – AdminBee Mar 11 '20 at 9:34
  • 1
    @AdminBee newer versions of ls output quoted results. Yes, it's awful, but that's what they've decided to do. – terdon Mar 11 '20 at 9:39
  • @terdon thanks, I had a suspicion it might be that, but I wanted to be sure (my ls is old enough not to do that ...) – AdminBee Mar 11 '20 at 9:51
  • @AdminBee I noticed when I do a cat plus tab on the directory the single quotes indeed are not present. – conteh Mar 11 '20 at 9:51
  • 1
    @conteh but you see the hidden dirs? That's odd. – terdon Mar 11 '20 at 9:52

If the only issue is that the directories are hidden, you can just remove the . from the beginning of their name to make them unhidden. For example, using perl-rename (called rename on Ubuntu):

rename 's/^\.//' '.\_Validate'*

Or, with just shell tools:

for dir in '.\_Validate'*; do echo mv "$dir" "${dir//.}"; done

Bot of these leave you with horrible directory names though, with spaces and slashes and other unsavory things. Since you're renaming, you may as well rename to something sane:

rename 's/^\.\\//; s/\s+/_/g' '.\_Validate'*

That will result in:

$ ls -d _*
_ValidateAll.sh_GL_100  _ValidateAll.sh_GL_107  _ValidateAll.sh_GL_114
_ValidateAll.sh_GL_101  _ValidateAll.sh_GL_108  _ValidateAll.sh_GL_115
_ValidateAll.sh_GL_102  _ValidateAll.sh_GL_109  _ValidateAll.sh_GL_116
_ValidateAll.sh_GL_103  _ValidateAll.sh_GL_110  _ValidateAll.sh_GL_117
_ValidateAll.sh_GL_104  _ValidateAll.sh_GL_111  _ValidateAll.sh_GL_118
_ValidateAll.sh_GL_105  _ValidateAll.sh_GL_112  _ValidateAll.sh_GL_119
_ValidateAll.sh_GL_106  _ValidateAll.sh_GL_113  _ValidateAll.sh_GL_120

IMPORTANT: note that I am not checking for file name collision. If you rename one of these to something that already exists, then you will overwrite the existing file.

  • that worked _ValidateAll.sh_GL_190/ – conteh Mar 11 '20 at 10:31

You can use GNU Parallel:

parallel mv {} '{=s/^\.\\_//=}' ::: '.\_ValidateAll'*

This will remove .\_ from the names.

To also replace spaces with _ run:

parallel mv {} '{=s/^\.\\_//; s/\s/_/g=}' ::: '.\_ValidateAll'*

In principle (and as you probably know), files and directories are hidden if their name starts with a .. Thus, you can make them "visible" again by removing that .. It can be done in bash using, the builtin string manipulation functions:

user@host$ for dir in '.\_ValidateAll'*; do newname="${dir#.}"; mv "$dir" "$newname"; done

You would be well-advised, however, to verify it works correctly by trying it beforehand with

user@host$ for dir in '.\_ValidateAll'*; do newname="${dir#.}"; echo "rename $dir to $newname"; done

Update: you should definitely follow the advice in @terdon's answer to make use of the opportunity and get rid of all special characters in that process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.