Questions tagged [extglob]

Extglob (extended pattern matching) is a form of wildcards supported by bash. With extglob a pattern can be almost as powerful as a regular expression.

Extglob must be enabled before using:

$ shopt -s extglob

Several extended pattern matching operators are then recognized.

?(pattern-list)   Matches zero or one occurrence of the given patterns
*(pattern-list)   Matches zero or more occurrences of the given patterns
+(pattern-list)   Matches one or more occurrences of the given patterns
@(pattern-list)   Matches one of the given patterns
!(pattern-list)   Matches anything except one of the given patterns

References:

20 questions
0
votes
1 answer

Extglob - Move all files not in a pattern but keep a specific one

Let's say I have a folder named /folder1/ with the following files: file.txt log-2018-01-22.log log-2018-01-21.log log-2018-01-20.log I want to move to /folder2/ all files that aren't a .log with the current date, except file.txt. Since today is…
JM Calil
  • 9
  • 5
0
votes
1 answer

Extglob syntax style matching in Ruby

I want to create a glob expression that recognises filenames that don't have any full stops (periods) in them, and use that expression within Ruby code. I realise that ordinary glob expressions can't do this. However, bash extglob has a syntax that…
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
0
votes
1 answer

Makefile: How to get wildcard (!arch)/*.c

I'm trying to make a makefile for compiling all the source files in my project, wich are spread in several directories like this: libc/ arch/ include/ math/ stdio/ And i want to exclude all the files from the arch and include directories, I…
0
votes
1 answer

UNIX command for moving all files and directories in a specific directory except for one individual file

I would like to move all files except fora specific one to the trash on a mac from a single directory. Instead of moving the files and folders within that directory I would like all files and folders to be moved individually to the trash. For this…
joshuatvernon
  • 1,530
  • 2
  • 23
  • 45
-1
votes
1 answer

Bash script to copy folder and contents without one file

I'm trying to copy a directories contents without one file. The problem i'm having is that the file is a few folders nested and the extglob operator fails to match. Assume the following folder structure: I would like to copy everything from…
Jarvis
  • 312
  • 3
  • 12
1
2