Skip to main content
typo
Source Link
jimmij
  • 48.7k
  • 20
  • 136
  • 141

If you are using zsh you can enclose in parenthesis () a list of so called glob qualifiers which select desired files. In your case, that would be

cp *(On[1,4]) ~/

Here On sorts file names alphabetically in reverse order and [1,4] takes only first 4 of them.

You can make this more robust by selecting only plain files (excluding directories, pipes etc.) with ., and also by appending -- to cp command in order to treat files which names begin with - properly, so:

cp -- *(.On[1,4]) ~

Add the D qualifier if you also want to consider hidden files (dot-files):

cp -- *(D.On[1,4]}) ~

If you are using zsh you can enclose in parenthesis () a list of so called glob qualifiers which select desired files. In your case, that would be

cp *(On[1,4]) ~/

Here On sorts file names alphabetically in reverse order and [1,4] takes only first 4 of them.

You can make this more robust by selecting only plain files (excluding directories, pipes etc.) with ., and also by appending -- to cp command in order to treat files which names begin with - properly, so:

cp -- *(.On[1,4]) ~

Add the D qualifier if you also want to consider hidden files (dot-files):

cp -- *(D.On[1,4]} ~

If you are using zsh you can enclose in parenthesis () a list of so called glob qualifiers which select desired files. In your case, that would be

cp *(On[1,4]) ~/

Here On sorts file names alphabetically in reverse order and [1,4] takes only first 4 of them.

You can make this more robust by selecting only plain files (excluding directories, pipes etc.) with ., and also by appending -- to cp command in order to treat files which names begin with - properly, so:

cp -- *(.On[1,4]) ~

Add the D qualifier if you also want to consider hidden files (dot-files):

cp -- *(D.On[1,4]) ~
added 108 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k

If you are using zsh you can enclose in parenthesis () a list of so called glob qualifiers which select desired files. In your case, that would be

cp *(On[1,4]) ~/

Here On sorts file names alphabetically in reverse order and [1,4] takes only first 4 of them.

You can make this more robust by selecting only plain files (excluding directories, pipes etc.) with ., and also by appending -- to cp command in order to treat files which names begin with - properly, so:

cp -- *(.On[1,4]) ~

Add the D qualifier if you also want to consider hidden files (dot-files):

cp -- *(D.On[1,4]} ~

If you are using zsh you can enclose in parenthesis () a list of so called glob qualifiers which select desired files. In your case, that would be

cp *(On[1,4]) ~/

Here On sorts file names alphabetically in reverse order and [1,4] takes only first 4 of them.

You can make this more robust by selecting only plain files (excluding directories, pipes etc.) with ., and also by appending -- to cp command in order to treat files which names begin with - properly, so:

cp -- *(.On[1,4]) ~

If you are using zsh you can enclose in parenthesis () a list of so called glob qualifiers which select desired files. In your case, that would be

cp *(On[1,4]) ~/

Here On sorts file names alphabetically in reverse order and [1,4] takes only first 4 of them.

You can make this more robust by selecting only plain files (excluding directories, pipes etc.) with ., and also by appending -- to cp command in order to treat files which names begin with - properly, so:

cp -- *(.On[1,4]) ~

Add the D qualifier if you also want to consider hidden files (dot-files):

cp -- *(D.On[1,4]} ~
edited body
Source Link
jimmij
  • 48.7k
  • 20
  • 136
  • 141

If you are using zsh you can enclose in parenthesis () a list of so called glob qualifiers which select desired files. In your case, that would be

cp *(On[1,4]) ~/

Here On sorts file names alphabetically in reverse order and [1,4] takes only first 4 of them.

You can make this more robust by selecting only plain files (excluding directories, pipes etc.) with ., and also by appending -- to cp command in order to treat filefiles which names beginsbegin with - properly, so:

cp -- *(.On[1,4]) ~

If you are using zsh you can enclose in parenthesis () a list of so called glob qualifiers which select desired files. In your case, that would be

cp *(On[1,4]) ~/

Here On sorts file names alphabetically in reverse order and [1,4] takes only first 4 of them.

You can make this more robust by selecting only plain files (excluding directories, pipes etc.) with ., and also by appending -- to cp command in order to treat file which names begins with - properly, so:

cp -- *(.On[1,4]) ~

If you are using zsh you can enclose in parenthesis () a list of so called glob qualifiers which select desired files. In your case, that would be

cp *(On[1,4]) ~/

Here On sorts file names alphabetically in reverse order and [1,4] takes only first 4 of them.

You can make this more robust by selecting only plain files (excluding directories, pipes etc.) with ., and also by appending -- to cp command in order to treat files which names begin with - properly, so:

cp -- *(.On[1,4]) ~
added 10 characters in body
Source Link
jimmij
  • 48.7k
  • 20
  • 136
  • 141
Loading
added 31 characters in body
Source Link
jimmij
  • 48.7k
  • 20
  • 136
  • 141
Loading
Source Link
jimmij
  • 48.7k
  • 20
  • 136
  • 141
Loading