Tagged Questions
1
vote
2answers
42 views
How to strip directory structure with command line (or script)
I have a large collection of files packed into a two-level directory structure with many, many, many folders.
In other words, I have a folder with a great many subfolders in it. There are no ...
5
votes
3answers
203 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 ...
1
vote
1answer
29 views
Can one move a relpath in one command?
This question is similar to one I asked recently, but the answers to that question, for the most part, do not extend to this one, AFAICT. The main difference between the two questions is that the ...
1
vote
2answers
90 views
Can one copy a relpath in one command?
I find myself doing this often enough that I wonder if there's a standard Unix way to do it:
% mkdir -p /TARGETDIR/relative/path/to
% cp ./relative/path/to/somefile /TARGETDIR/relative/path/to
In ...
4
votes
8answers
148 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
761 views
How to make a Desktop “shortcut” that opens the terminal but under a different directory than the default home?
Objective
I am looking for an easy way to consistently run a terminal that automatically opens to a specific directory. Is there a way to do that without changing the default directory?
Preferably I ...
3
votes
2answers
384 views
How do I get this find and rename command to work with subdirectories? [duplicate]
Possible Duplicate:
Recursive rename files and directories
I have a large directory of music files that is often changing as files and directories come and go. My preference is to make sure ...
7
votes
2answers
347 views
How can I cd to the previous/next sibling directory?
I often have a project directory layout like this
project
`-- component-a
| `-- files...
`-- component-b
| `-- files...
`-- component-c
`-- files...
I'll usually be working in one of the ...
0
votes
1answer
321 views
OSX : rmdir “permission denied” but directory removed
This is a question from a newbie trying to learn UNIX commands.
I was trying to test the rmdir command by removing a test directory located in my Downloads directory. I have read and write rights on ...
9
votes
4answers
611 views
Best method to collect a random sample from a collection of files
Suppose there is a directory holding 300 data files. I want to randomly select 200 of those files and move them into another directory. Is there a way to do that under Unix/Linux?
3
votes
2answers
645 views
How do I create a ZIP archive that preserves only the structure of the target directory and below?
I need to create a zip archive where the unzipped result preserves the directory structure from the specified directory down. I also need to do this without actually switching to the directory.
My ...
29
votes
3answers
890 views
How can I cd to a directory just by typing the directory's name?
I either had this somewhere 20 years ago or I dreamed about it.
Basically:
If if type blobblob I get
blobblob: command not found
Fair enough.
I would like it so that when my shell gets those ...
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
...
3
votes
1answer
68 views
What is the best way to find directories that exactly match a string irrespective of the path?
Suppose I have the directories:
/foo/
/A/B/C/foo/D/E/
/F/foo/G/H/foo/I/
How can get a result that lists all the directories whose basename exactly matches
a given string (for example foo in here)?
...
7
votes
3answers
2k views
Simplest way to password protect a directory and its contents without having to create new files?
I would like to password protect or encrypt a directory and all the files within it (for the whole directory tree below it). I do not want to bother the whole home directory, I want a specific ...
5
votes
3answers
292 views
Equivalent of forward/back buttons for unix shell (when navigating directories)?
I'd like to be able to type in terminal commands of forward/back especially if I went from a directory with a super-long name to home (and want to return back to the directory with the super-long ...
7
votes
2answers
224 views
Is there a correct way to list the subdirectories of the current directory?
I can find the subdirectories of a directory by
ls -d -- */
or
ls -l | grep "^d"
but both of these seem indirect, and I would imagine that there would be a standard way to find just the ...
8
votes
3answers
473 views
Lowercasing all directories under a directory
I want to lowercase every directories' name under a directory. With which commands can I do that?
4
votes
2answers
1k views
Is there a way to empty the trash/wastebasket from the command line?
This would be great especially considering the latest version of Ubuntu is very slow when displaying directories on my PC...
6
votes
3answers
4k views
How can I move files by type recursively from a directory and its sub-directories to another directory?
What would be a good way to move a file type from a directory and all of its sub-directories?
Like "move all *.ogg in /thisdir recursively to /somedir". I tried a couple of things; my best effort was ...
8
votes
6answers
481 views
Best way run a command on each file in a directory tree
There appear be a number of ways to do this including loops in shell script, find and xargs. Which of these is best, and which is most portable?
