Tagged Questions
2
votes
3answers
78 views
Filter a list of strings using math
I have a directory with files listed like so:
abc201303130110.txt
abc201303140511.txt
abc201303150112.txt
As you can see, the filename contains a datetime stamp. I want to return all files with the ...
1
vote
1answer
75 views
How to prevent double escaping?
I'm trying to put a bunch of images together into a pdf. I ran gm convert *.jpg out.pdf and it worked, but the images were not in the right order.
I found that ls -v orders them correctly so then I ...
1
vote
3answers
123 views
Reading a directory in shell script
I want to read a numbered directory which is under a path, into a variable in shell script.
The paths are something like this:
.../releases/R1/...
.../releases/R2/...
.../releases/R3/...
Each time ...
7
votes
1answer
134 views
What is the significance of the dot in bash commands and how is it different from an asterisk?
I'm trying to understand the significance of the dot in bash and how it differs from an asterisk. Can someone please elaborate? For example, what's the difference between cp -ar /foo/. /foo2/ and cp ...
5
votes
2answers
146 views
How to put the specific files from a directory in an array in bash?
Suppose I have a directory under which there are 3 files named: file1.txt,file2.txt and file3.txt.
Now how can I fill an array with those file names(I just know that all the files have certain ...
5
votes
3answers
335 views
Glob with Numerical Order
I have this list of pdf files in a directory:
c0.pdf c12.pdf c15.pdf c18.pdf c20.pdf c4.pdf c7.pdf
c10.pdf c13.pdf c16.pdf c19.pdf c2.pdf c5.pdf c8.pdf
c11.pdf c14.pdf c17.pdf c1.pdf ...
3
votes
5answers
392 views
How do I extract all .htaccess files from a tarball?
I want to extract all .htaccess files from a tarball, how can I do so? I see only one mention of "include" in the manual page of tar which is not related with an option for including only certain ...
2
votes
3answers
91 views
Selecting latest files and grouping by name
I have a directory containing files of the following name structure.
<device>.<yyyy-mm-dd-hh-mm-ss>
I am working on a script that will retain the the last X copies of these ...
4
votes
4answers
286 views
Find files without a number
I am trying to write a simple script that will iterate through all drives except sda. Right now I have this
for i in $(find /dev/ -name "sd*" ! -name "sda*")
do
echo $i
done
However this ...
2
votes
1answer
500 views
shopt -s nocaseglob is not working on Ubuntu
Case insensitive file name globbing is not working in bash on Ubuntu 11.04 64bit. The shell options specified in .bashrc are as follows:
shopt -s nocaseglob
shopt -s nocasematch
shopt also shows ...
3
votes
2answers
140 views
returning strings corresponding to shell glob matching
Suppose I have a subdirectory called sub. Then I want to operate on all files in that directory with the extension "txt". I want something like
for f in sub/*.txt
do
enscript -b "" -o {$f ...