All Questions
68 questions
1
vote
3
answers
1k
views
How to do wildcard/glob expansion when the pattern and the resolved pathes contain spaces?
I need to expand some pathes using a POSIX sh or Bash:
Here are two example patterns (I chose overly complicated patterns on purpose):
$ npm pkg get workspaces | jq -r '.[]'
apps/app*
lib/{be,fe *} ...
-4
votes
1
answer
157
views
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 ...
1
vote
2
answers
270
views
Getting an array of files built from include array and exclude array containing globs
I am wanting to do the following:
Define an array of globs that specify a base collection of files to include in a process.
Define an array of globs that specify files to exclude from that process. ...
0
votes
1
answer
198
views
How to copy files from a list without extension to a different folder?
I have a text file that contains a list of ids of files without any extension now I need to copy those files mentioned in the list
head 01cBC.txt
EE87786
EE87787
EE87788
EE87789
EE87790
EE87791
Now, ...
2
votes
2
answers
3k
views
'For' loop won’t iterate over list when path given as argument
I'm practicing shell scripts and am trying to make a simple script that takes a directory as an argument, loops through each file within and prints out its name and size.
#!/bin/bash
# A practice ...
0
votes
1
answer
418
views
Passing arguments into a glob pattern within a script
I have a script called get_numbers.sh, which I want to use to extract data from .pdf files labelled sequentially by date, using pdfgrep.
Let me simplify my problem to what I believe are its essentials:...
0
votes
2
answers
288
views
How to load more than 10 files with range in executable args? [duplicate]
I have this working command line expression:
program --files path_to_mydir/mydata_[0-9].csv
I would like to go from [0-100] but this is not working.
program --files path_to_mydir/mydata_[0-100].csv
...
0
votes
1
answer
4k
views
syntax error near unexpected token
I'm running this command in jenkins, and it's using sh.
However I'm not sure what this error means in my bash script
#! /bin/sh
for d in $(ls -d kube/xx/bb/!(abc*|!cdf*)/ | xargs -I {} basename {} ) ;...
0
votes
2
answers
286
views
Iterate groups of files in for loop
I have a set of files like this:
A1.xlsx
A2.xlsx
B1.xlsx
C1.xlsx
C2.xlsx
I only know the prefixes (A, B, C) but the rest of the name is unknown beforehand, and so is the number of files.
I need to ...
0
votes
1
answer
43
views
Help with understanding use of Big Bracket in this Context
[ ! -d ~/.ssh ] && mkdir ~/.ssh;
I cannot understand the use of [] here and what does this mean. Although I understand the later part I cannot relate [ ! -d ~/.ssh ] with mkdir ~/.ssh
...
0
votes
1
answer
6k
views
Move files with wildcard?
Ohhhh, I've read a few pages and questions, but I just can't comprehend/fully understand it...
jdir0="$@" # /home/tor/subbackup/teest2/jjj
mv "$jdir0/subs/*.srt" /home/tor/...
1
vote
1
answer
2k
views
How to apply the ! (not) operator in simple terminal commands [duplicate]
It seems to be a really simple thing to do. I have done it in my Bash scripts, but I wonder how to do the same in the terminal.
For example, suppose I want to ls all files that are not js. Probably I ...
3
votes
2
answers
1k
views
Globbing within a parameter expansion
I'm trying to select the files within a set of directories passed as arguments with the following:
${@/%/*}
However, this is not ideal, since paths with spaces will break, and quoting the parameter ...
2
votes
1
answer
587
views
How to display different directory content with Bash select command?
So far I have found some examples of Bash select function usage with logical constructed options or Asterisk one (i.e select s in *). This last one lists all actual directory content.
So I would like ...
0
votes
1
answer
328
views
piping ls to other programs vs loop globbing [duplicate]
I am reading about the pitfalls of parsing ls and the examples given are about looping ls with for/while. The article title says 'parsing ls' - does that mean piping the output of ls to awk and other ...