Tagged Questions
5
votes
3answers
208 views
How do I remove all sub-directories from within a directory?
This question is kind of a phase II to the first question I posted at here
I have a directory that contains a bunch of sub-directories, .zip files, and other random files not contained within a ...
4
votes
8answers
156 views
Run a command on all subfolders
If you have a series of subfolders (like from a to z) and want to run a command on each one of them (like rm *.pdf or ls *.pdf), how do you do that? The "manual" approach would be cd a, rm *.pdf, or ...
3
votes
1answer
61 views
Passing all files of specific filetype in current and subdirectories
I have constructed an elaborate 500+ character command with many arguments and switches to autosign multiple PDF documents.
I'm using JSignPDF and I'd like to use it's batch mode including the ...
27
votes
5answers
2k views
The result of ls * , ls ** and ls ***
I know using the command ls will list all the directories. But what does the ls * command do ? I used it and it just lists the directories. Is the star in front of ls means how deep it can list the ...
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 ...
7
votes
7answers
550 views
How do I create a directory in all subdirectories?
Suppose I have a directory structure like this:
$ [~/practice] ls
a/ b/ c/ d/
Now I want to create a directory tmp1 in all sub directories of practice and I do this:
$ [~/practice] mkdir */tmp1
...
9
votes
3answers
323 views
what is wild card to select all directories in a directory
i want to set sticky bit for all directories in a directory excluding files. is there any wild card to do this?
#sudo chmod g+s /var/www/<WILD_CARD_FOR_ALL_DIRECTORIES>
2
votes
2answers
201 views
Using wildcards to match a directory in bash
Lets say the folder structure is like so:
/home/
--user1/asdf
--user2/asdf1234
--user3/asdf325234
--cool/asdf
How could I change to asdf1234 without specifying the user? For example:
cd ...
1
vote
5answers
924 views
ls: Do not show directories that match same pattern in wildcard searches, only files
Supposing I have something like the following, a typical business PC situation:
drwxr-xr-x 1 whatever whoever 3 Oct 3 16:40 invoices2009
drwxr-xr-x 1 whatever whoever 4 Oct 3 16:40 ...
2
votes
2answers
207 views
Untar directory from large tarball
How do I untar a directory that I don't know the path to? I only know the directory name.
I know how to untar a single file with a wildcard: tar -xf somefile.tar.gz --wildcards --no-anchored ...
4
votes
1answer
128 views
What is the tool that allows me to specify arbitrary directories using **
I once saw a colleague uses a tool which allows to use ** to represent any directories. For example: if a file called myfile.java sits deep inside:
src/main/com/mycompany/product/store/myfile.java
...
11
votes
4answers
448 views
How do I choose specific files in a different directory using bash?
I want to list (or delete, or do some other operation) on certain files in a directory, like this:
$ ls /opt/somedir/
aa bb cc aa.txt bb.txt cc.txt
$ ls /opt/somedir/(aa|bb|cc) ## pseudo-bash ...
7
votes
6answers
4k views
What's the best way to count the number of files in a directory?
If parsing the output of ls is dangerous because it can break on some funky characters (spaces, \n, ... ), what's the best way to know the number of files in a directory?
I usualy rely on find to ...
5
votes
3answers
264 views
“mkdir foo; svn mv * foo”
I often want to do some variant of this idiom:
$ mkdir 2010
$ svn mv * 2010
Of course, I get an error because the glob matches 2010 as well:
svn: Cannot copy path '2010' into its own child ...