List file excluding first letter

Asked

Viewed 143 times

1

I have a file called 1arquivo and I list him normally with the command ls. How can I use ls deleting the first letter to return me only arquivo. It has to be a generic solution because I will have several files in this same situation.

  • your question has been answered?

1 answer

4

using cut your command would look like this:

ls ?arquivo | cut -c2-80

using awk command is like this:

ls ?arquivo | awk '{ print substr($0,2,length($0)); }'

Only for teaching levels: using regular expression this ? is equivalent to any character ? file can be (1st file,2file,3file), and this code * is equivalent to anything or is (1st file, julioarquivo, 09999file).

I hope I’ve helped.

  • ls | cut -c 2-

Browser other questions tagged

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