How to hide files programmatically

Asked

Viewed 59 times

0

A hidden file in a linux environment has a point (.) before its name, so that for example: .arquivo.c is hidden and arquivo.c isn’t. Knowing that, my question is, how to hide a number of files programmatically? And if I can go further, how to hide files only from a certain extension?

I’m aware of two possibilities so far:

  • Renaming them, one by one.
  • Using a file .hidden¹.

However the first option seems to me unfeasible and the second, despite being exactly what I’m looking for, was not effective in the environment where I work, of a Raspberry. There is another option?


¹A . Hidden is used to determine what will be hidden in a given directory.

  • Was not effective in what sense?

  • It didn’t work. I created a file. Hidden, listed some files to hide and nothing happened.

  • Why would the first option be unfeasible?

  • @because there is some method capable of doing what I am looking for more efficiently. Hidden, if it served me, would already solve a lot.

  • @Caiodepaulasilva Sorry, could edit your question by also putting the code or the method you did to try to hide?

  • 1

    the method using the . Hidden file only works with the Nautilus file manager of the Gnome environment, as far as I know...in the terminal does not work

  • @zentrunix came to similar conclusion. I kept the question open in the hope of there being a solution that I do not know.

Show 2 more comments

1 answer

0

Well, if I understood the meaning of 'programmatic' I think I would want to read about regex. So, using the pipe straight into the terminal you can do what you’re looking for:

ls -1 | grep "\.<extensão>$" | xargs -i mv {} .{}

Of course, the above solution is quite simple and will have to be run from directory to directory.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.