wildcards

zsh: What does (DN) mean?

zsh: What does (DN) mean? I have seen that to copy or move directory contents, including hidden files and folders in this directory, to another one, some people use the "mysterious" (DN) thing. cp -R dir1/*(DN) dir2/ mv dir/*(DN) dir2/ It seems man cp and man mv don’t mention it. What is it, and where …

Total answers: 1

Untangling pathname expansion and quote removal in echo 'a'*

Untangling pathname expansion and quote removal in echo 'a'* Shell is: GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu) In the current working directory, there are two files: a file named abc.txt a file named ‘a’bc.txt (created with touch ‘a’bc.txt) I run the following command: echo ‘a’* The output is: abc.txt The GNU bash manual specifies that quote …

Total answers: 1

As soon as I touch a new file, my ls command with grep stops working

As soon as I touch a new file, my ls command with grep stops working I’m trying to find all the files in my home directory with a specific extension. If I only have one instance of the file extension, the ls command works perfectly fine, but as soon as I touch a new file …

Total answers: 1

Expand a list of files including globs, which are defined in a file

Expand a list of files including globs, which are defined in a file I’m using bash. Suppose I have a file named filelist, which contains a list of files: stuff/**/*.csv # to keep it simple (without loops), assume just one entry #*.txt #foo.md #bar.bin And I want to expand that: ls $(cat filelist) I get: …

Total answers: 1

Command line glob to view multiple images using ImageMagick's display

Command line glob to view multiple images using ImageMagick's display How can I open multiple images files using ImageMagick’s display command? If I enter say display *.png in a directory containing multiple PNG files, only one is displayed. I think I’d prefer them to appear one at a time, but all at once could be …

Total answers: 2

How to reuse matched value in bash globbing?

How to reuse matched value in bash globbing? I was wondering whether it is possible to reuse whatever was matched in a path with globbing? (Just as it can usually be done with regex substitutions?) I’m aware that there are other solutions for the following example, but I’m just using it as an example for …

Total answers: 1

cp some/path/**/*.h is not including .h files at all depths

cp some/path/**/*.h is not including .h files at all depths I’m trying to copy all .h files in a directory and all subdirectories into another folder using the copy command: cp –parents -r tensorflow/lite/**/*.h libtensorflowlite-2.13.0-linux/include The above glob only copies .h files in tensorflow/lite/XXX/*.h and doesn’t include .h files further down (eg. tensorflow/lite/XXX/XXX.h) or in …

Total answers: 2

Expand a wildcard matching single directory/file

Expand a wildcard matching single directory/file This works beautifully in BASH: $ where=/sys/class/backlight/* $ echo $where /sys/class/backlight/intel_backlight However when put in the POSIX script with /bin/sh as an interpreter, this doesn’t work, where becomes /sys/class/backlight/*. I’ve tried to Google but probably I’m not using the right terms. Asked By: Artem S. Tashkinov || Source The …

Total answers: 1

Syntax error when "cp" statement with extended globbing options is moved to an "if" block

Syntax error when "cp" statement with extended globbing options is moved to an "if" block Having some trouble doing a copy in Bash. This works fine: # Enable extended globbing and include filenames beginning with a ‘.’ shopt -s extglob dotglob # Copy git repo to expected place cp -r !($YOCTO_DIR) $POKY_DIR/$GIT_REPO_NAME/ But when I …

Total answers: 1

in zsh, strip and add a suffix in a single glob pattern

in zsh, strip and add a suffix in a single glob pattern Suppose I have a file named foo.md.md (the reason for the double suffix will become apparent). $ print *.md(om[1]) # Get the most recent .md file foo.md.md $ print *.md(om[1]:r) # Strip the suffix foo.md $ print *.md(om[1]:r).docx # Try to add a …

Total answers: 3

for loop over directory glob with space won't work

for loop over directory glob with space won't work I’m attempting to recursively work on directories and files, that are mirrored at second location The function I defined is: #!/bin/bash set -e shopt -s nullglob shopt -s dotglob dom() { echo "Dirs:"; for elem in "$1/*/"; do if test -d "$elem"; then echo is Dir …

Total answers: 2

Glob pattern matching comma separated numbers

Glob pattern matching comma separated numbers I want to write a glob pattern to match numbers separated by commas. What would the pattern be like? Here are some examples 5 5,8,13 Have started with the following, but there some problem with it, as I do not get a match. var="8,13,21" echo "var: $var" if [[ …

Total answers: 3

Eliminating ^ and $ in pattern matching

Eliminating ^ and $ in pattern matching Am using the following regex condition, with ^ and $ to represent the start and end of the given pattern. if [[ "$1" =~ ^[[:digit:]]+$ ]]; then I have also written the equivalent glob condition if [[ "$1" == ^+([[:digit:]])$ ]]; then Because I have seen some people …

Total answers: 1

Glob and regex matching

Glob and regex matching Bash has two types of pattern matching, Glob and Regex. The general rule of usage seems to be that 1) the simpler glob is done to search filenames 2) regex is used for searching text. Glob uses the metacharacters at the front, regex uses the metacharacters at the end of the …

Total answers: 1

extract last part of filename using echo – having assigned variables using wildcards

extract last part of filename using echo – having assigned variables using wildcards I am trying to extract parts of a filename, where I want to extract everything after the first _ and I have found a working solution, see below file=22NGS71294_S191_R1_001.fastq.gz echo $file 22NGS71294_S191_R1_001.fastq.gz echo ${file#*[_ ]} S191_R1_001.fastq.gz but, when I use wildcards, it …

Total answers: 1

How to remove similar folder from multiple locations in terminal

How to remove similar folder from multiple locations in terminal I have a folder ‘reg_standard’ nested within 68 different folders that I want to remove. The path to this folder looks something like: /Volumes/…/sub-???/run_?.feat/reg_standard where ‘?’ is a stand-in for all the different folders that start with ‘sub’ or ‘run’. For example, I have sub-101, …

Total answers: 2

Wildcard doesn't work in a "for f in …" for a different directory (and partition)

Wildcard doesn't work in a "for f in …" for a different directory (and partition) testingfilesizecheck.sh: line 6: /media/doctor/123A123E1A123456/Users/Tim/Downloads/PokemonRed/Binary House/Final Structure Directory/Category/* I am using the command for f in "/media/doctor/123A123E1A123456/Users/Tim/Downloads/PokemonRed/Binary House/Final Structure Directory/Category/*" If I am very specific about it and say "/media/doctor/123A123E1A123456/Users/Tim/Downloads/PokemonRed/Binary House/Final Structure Directory/Category/ABRA.bin" then it will work. I am new to …

Total answers: 2