I am learning Unix online and i came across this question to create a hierarchical structure. I have created the directories using mkdir command but I am stuck while creating the files inside directory.    My command for creating directories is  mkdir -p mydir/{colors/{basic,blended},shape,animals/{mammals,reptiles}}
23385
I know that touch command creates a file:  touch test1.txt   but how I can create a file and its full path?  for example my desktop contains nothing:  ~/Desktop/$ ls ~/Desktop/$   and I want to create 1.txt in ~/Desktop/a/b/c/d/e/f/g/h/1.txt. Can I do this with a simple command like:  $ touch ~/Desktop/a/b/c/d/e/f/g/h/1.txt   instead of create full path manually and then create the file?
65256
I am trying to copy the contents of a folder to another folder in a different directory using terminal.  Would somebody be able to provide me an example of the command line syntax required to achieve this?
86640
I have two questions. First, which command lists files and directories, but lists directories first?  Second question: I want to copy a list of files into a single directory, but make the target directory the first filename in the command.
49090
I wish to recursively go through the folders of a directory structure and copy any .jpg I find into another directory.  I think I had the wrong idea with:  cp -R photos/*.jpg /cpjpg   How can I do this from the command line in Ubuntu?
38564
Situation :  $ mkdir foo &amp;&amp; touch foo/.test $ cp foo/* . zsh: no matches found: foo/* (or bash : cp: cannot stat ‘foo/*’: No such file or directory)   I have a directory full of hidden folders and files. What is happening and what is the solution?
58405
I have the 1st edition of The Unix Programming Environment book. In chapter 2, the authors state that directories are readable as files, and mention some facts about the format of these files. They give some usage examples such as cat . (in exercise 2-2).  At least in Darwin, directories are no longer readable as files. At least, they appear to be zero-length files when read.  When did this change occur, and is there any official documentation about it?
34127
I have multiple files in multiple folders under one directory that need to be in one folder. Is there a command line that can help me accomplish this?
15047
Quite often I need to perform this two commands:  mkdir abc cd abc   I am curious whether there is a simple command (or an alias that I can create and use) to do it in one go, like  user@GROUP:~$ mdcd abc user@GROUP:~/abc$   Is this possible?
71174
I'm currently developing a fake filesystem for a browsergame. I recently implemented ".." and "." folders so every folder has a reference to its parent. Then I checked in my terminal if "/" also has these folders.  Actually I was very surprised that it has a directory ".." which obviously is a reference to itself.  Is the reason for this consistency or is there a better explanation?  Edit: I'm basically looking for the document where this is documented.
13829
This is a situation I often find myself in:  mkdir /Some/really/long/path/to/a/directory/ cd /Some/really/long/path/to/a/directory/   I know that ideally you would cd /Some/...etc.../a/ and then mkdir directory, but I've often performed mkdir first and then had to cd to the end of the same lengthy file path I just created.  Short of doing...  var="/Some/...etc.../a/" mkdir $var/directory; cd $var   ...which is even worse, is there some way to reuse the parameter passed to the previous command? I'm aware of course of tab completion, but in a series of nested directories with similar names this doesn't always help that much. Ideally, I'm hoping for a shortcut like $# or $@.  Failing this, the next best time-saving solution would be equally appreciated!
8872
I've got a folder full of folders, and some of those folders may or may not have folders in them. It looks something like this:  ~/stuff/01.d/01/files ~/stuff/02.d/files ~/stuff/03.d/files ~/stuff/04.d/lol/files ~/stuff/05.d/files   I want to make separate .rars for each of the folders in ~/stuff, so I was going to do for f in *.d; do rar a "${f//.d/.rar}" "$f"; done which worked great, and gave me the rars. But I'd rather have no directory structure in the rars at all, just files. Is there an easy way to do this? It seemed like one of the switches looked like it might have done what I wanted, but the man page is a bit confusing. I'll try a few things.  I may end up trying to figure out a bash script to cd into the directory, check if it's the files, if so make the .rar in the parent (../${f//.d/.rar}), else go into the directory again and make the rar two parents up (../../${f//.d/.rar}). In this case, I'd want rar a ../"${f//.d/.rar}" * I think, I haven't tested it.
72629
Let's say the directory ~/this_dir doesn't exist.  I need to be able to run touch ~/this_dir/new.txt to create new.txt in ~/this_dir.  Is there a simple way to make touch also create the directory?  Or an alternative command which would achieve the same thing?  Thanks
71753
I've seen in many places used install -d to create directories and install -c to copy a file. Why not use mkdir and cp? Is there an advantage in using install?
117235
I have created directories in root. I am looking for the chmod command to allow all users read and write permissions to a specific directory. I have done chmod 775 for a file but I need this for a directory. This includes permissions on all files and sub directories.
49052
I was trying to test out this buggy/new tool to see how it works, and it prompted me to choose a directory to use for stuff I am doing. From the directory ~/Code/indep, I typed in ~/Code/indep/tarbell. (Stupid, I could have just typed 'tarbell', but whatever.) It prompted me to create it because it didn't exist, I said yes. When I inspected the contents of this directory, here is what I see:  brian@navis:~/Code/indep$ ls ~ project1 project2 project3 ...   I thought "oh, weird, it created a symlink to ~". However:  brian@navis:~/Code/indep$ file ./~ ./~: directory   file thinks it's a directory.   brian@navis:~/Code/indep$ ls -l drwxr-xr-x 3 brian brian 4096 Nov  8 16:50 ~ drwxr-xr-x 8 brian brian 4096 Oct 14 18:42 project1 drwxr-xr-x 3 brian brian 4096 Sep 10 21:15 project2 drwxr-xr-x 5 brian brian 4096 Oct 14 19:33 project3 ...   And so does ls -l.   I thought, "oh, ... is it a hard link? I've never really used those." But I tried to reproduce, and it's impossible to create a hard link to a directory. So... I guess I've narrowed this down to things I don't understand. Did I mount my home directory in this other directory somehow?   My main goal at this point is to remove the reference to my home directory in this folder (rm doesn't seem like the answer), but I'm also curious to know what's going on.  EDIT:   In retrospect, I understand exactly what happened. As was answered below, the program created a directory called "~" inside my current directory. The only really obfuscating fact about this is that I wasn't consistent with how I was actually viewing what the directory was. Sometimes I referred to it as  "~" and sometimes as "./~". It's only if you do the latter that you can actually see what's going on, but until I understood this, I was conflating what I was seeing from using the absolute path of "~" to to what was in fact a local directory.
27723
I have a single directory that contains dozens of directories inside of it.  I'm new to command line and I'm struggling to come up with a command that will zip each sub-directory into a unique sub-directory.zip file.  So in the end my primary directory will be filled with all of my original sub-directories, plus the corresponding .zip files that contain the zipped up content of each sub-directory.  Is something like this possible? If so, please show me how it's done.
87039
I'm looking for a way to batch create a folder followed by sub-folders.  I'm looking at something like  c:\users\user\desktop\sample\1 c:\users\user\desktop\sample\2   etc.  Any ideas?  I'd prefer .cmd/PowerShell methods to do so.   If there's a way to do so via a terminal, I'll be happy to attempt any ideas/solutions by booting into a Linux live disc via usb.