Skip to main content
7 votes
Accepted

Zsh: Copy or Move symlinks to regular files, but not symlinks to directories (or vice versa)

Use the - qualifier for the following qualifiers to apply after symlink resolution, combined with @ (before the -!) to test for symlinks. cp -- *(@-.) /symlinks/to/regular/files/ cp -- *(@-/) /...
Stéphane Chazelas's user avatar
6 votes

BASH - Find file with regex - Non-recursively delete number-only filenames in directory

No need for regexps, LC_ALL=C find . ! -name '*[!0-9]*' -type f -delete Non-recursively (and that applies for all find commands below), add -maxdepth 1 if supported, or change to: LC_ALL=C find . ! -...
Stéphane Chazelas's user avatar
3 votes

Find and delete files from unix directory of multiple patterns

I find it puzzling that you need to find them and delete them. It would seem sufficient to simply delete them. The rm command does "the finding" for you: rm -- *_bkp *_backup *_bak.csv If ...
Jim L.'s user avatar
  • 8,322
3 votes

Find and delete files from unix directory of multiple patterns

I would use find for this: $ find . -iname '*_backup' -o -iname '*_bkp' -o -iname '*_bak.csv' ./A001.txt_bkp ./A003_bak.csv ./A002.csv_backup Here the . parameter means "from the current ...
Kingsley's user avatar
  • 337
3 votes

Find and delete files from unix directory of multiple patterns

With bash modern shell: printf 'rm %s\n' *@(bkp|backup|bak)* Replace printf 'rm %s\n' with rm, when happy with the output. This use extglob capability. Extended globs: shopt -s extglob allow you to ...
Gilles Quénot's user avatar
3 votes

gnu grep multiple filters in one regex

The command you can use is: cut -f1 -d: .pgpass | grep -E '^FISP.*(CDS|TAP).*PGS401' The will search for (regex) ^FISP.*CDS.*PGS401 or ^FISP.*TAP.*PGS401 Here is the result of execution, based on the ...
Romeo Ninov's user avatar
  • 18.1k
1 vote

gnu grep multiple filters in one regex

I'd try using \ to flip the "special" state* of your ()|s. You can do it like this: grep '^FISP\(CDS\|TAP\)PGS401' "special" state: prefacing a character with \ flips it from &...
waltinator's user avatar
  • 5,465

Only top scored, non community-wiki answers of a minimum length are eligible