This is quite possibly just a silly question, and I suspect I already know the answer, but I might learn something new, so ... I recently learned about the CDPATH environment variable, which lists a number of directories for cd to search through - in a sense joining those directories to the current directory, and I wondered if there is something similar for ls and other commands - so that ls would list not only the current directory, but the ones that are 'joined' to it, and the files will be available as files in the current directory. One reason why it might be desirable is if you have a directory with a number of files that you want to be visible in the home directories of several users. I'm not saying this would be hugely useful or beneficial, and I know a number of ways in which to achieve a similar effect, eg with symbolic links; it was just a thought experiment.
121145
I am trying to connect two folders from two different locations to one folder from which radio software plays music.  This is what I have done so far:   In /etc/fstab I have put the following two lines:  /usr/local/centovacast/var/vhosts/adminaw/var/spool/media   /mnt/mounted-drive/awmusic_songs/   none   bind /usr/local/centovacast/var/vhosts/adminaw/var/spool/media   /home/centos/awmusic_songs_1/   none   bind  Then I have run the following two commands:  mount --bind /mnt/mounted-drive/awmusic_songs/ /usr/local/centovacast/var/vhosts/adminaw/var/spool/media mount --bind /home/centos/awmusic_songs_1/ /usr/local/centovacast/var/vhosts/adminaw/var/spool/media    So basically, the radio software reads music from /usr/local/centovacast/var/vhosts/adminaw/var/spool/media, and the songs are in the folders awmusic_songs and awmusic_songs_1.  After I have done what I have described above I only see files (songs) from the second folder (awmusic_songs_1).  Is it possible what I am trying to achieve? If so, could someone please help me?
22102
I am using Precise pangolin. As far as I know, commands like   cd..   or   cd-   are used to browse through folders in the terminal.  But whenever I enter one of this commands, it gives an error saying no such command or filename found. Do I have to perform any additional task before I use commands involving cd?
12023
I'm currently in a symbolic link directory and I want to go up one level in the absolute path, but I cant as it will hit me back up to my home directory (~). I can do pwd -P to get the absolute path, but how do I pipe that result into the cd command? I always thought it was this: {}   Sample:  10:21:55 {master *} ~/ch$ pwd -P  /home/drupal/sites/all/themes/house  10:22:16 {master *} ~/ch$ pwd -P | cd {} bash: cd: {}: No such file or directory  10:22:20 {master *} ~/ch$
81942
In the past, I learned that in Linux/UNIX file systems, directories are just files, which contain the filenames and inode numbers of the files inside the directory.   Is there a simple way to see the content of a directory? I mean the way the files names and inodes are stored/organized.  I'm not looking for ls, find or something similiar. I also don't want to see the content of the files inside a directory. I want to see the implementation of the directories. If every directory is just a text file with some content, maybe a simple way exists to see the content of this text file.  In the bash in Linux it is not possible to do a cat folder. The output is just Is a directory.  Update The question  addresses the same issue but it has no helpful solution like the one from .
49044
I have a utility consisting of a couple of directories with some bash scripts and supporting files that will be deployed to several machines,  possibly in a different directory on each machine. The scripts need to be able to reference paths relative to themselves, so I need to be able to get the path to the file that's currently being executed. I am aware of the dirname $0 idiom which works perfectly when my script is called directly. Unfortunately there is a desire to be able to create symlinks to these scripts from a totally different directory and still have the relative pathing logic work. An example of the overall directory structure is as follows: /  |-usr/local/lib  |  |-foo  |  |  |-bin  |  |  |  |-script.sh  |  |  |-res  |  |  |  |-resource_file.txt  |-home/mike/bin  |  |-link_to_script (symlink to /usr/local/lib/foo/bin/script.sh)  How can I reliably reference /usr/local/lib/foo/res/resource_file.txt from script.sh whether it is invoked by /usr/local/lib/foo/bin/script.sh or ~mike/bin/link_to_script?
111273
Sometimes, I need to check only the directories not files. Is there any option with the command ls? Or is there any utility for doing that?  EDIT: I'm using Mac OS X, and ls -d gives me . even though I have directories.
111963
Is there a way to list a set of say, 30 random files from a directory using standard Linux commands? (in zsh)  The top answer described  does not work for me (sort does not recognize the option -R)
92926
I've been trying to find the difference between using the dir and ls commands in terminal. I know ls is the traditional UNIX method of viewing the files in a directory, and that dir is the windows command prompt equivalent, but both commands work in terminal.   If I type in dir, it displays the files and folders in the directory, and if I type ls, it does the same, except with content highlighting. Both commands accept options (i.e. ls -a and dir -a both return all files and folders and hidden files.   So does anyone know what the difference is and why both dir and ls are used?
71137
Given an absolute or relative path (in a Unix-like system), I would like to determine the full path of the target after resolving any intermediate symlinks. Bonus points for also resolving ~username notation at the same time.  If the target is a directory, it might be possible to chdir() into the directory and then call getcwd(), but I really want to do this from a shell script rather than writing a C helper. Unfortunately, shells have a tendency to try to hide the existence of symlinks from the user (this is bash on OS X):  $ ls -ld foo bar drwxr-xr-x   2 greg  greg  68 Aug 11 22:36 bar lrwxr-xr-x   1 greg  greg   3 Aug 11 22:36 foo -&gt; bar $ cd foo $ pwd /Users/greg/tmp/foo $   What I want is a function resolve() such that when executed from the tmp directory in the above example, resolve("foo") == "/Users/greg/tmp/bar".
81209
I'm trying to put together a generic script that will check the existence of several key directories for various users on different servers. Additionally, I want to leverage each user's $HOME variable.  For eg, let's say this were true:   on server 1: jdoe's home is /home/jdoe  on server 2: jdoe's home is /opt/jdoe2 server 3 hasn't been built yet; we won't know where they build his $HOME until the server is built. on server 4: mysql's home is /opt/home/mysql   This is what I have for my important directories (ordered from most to least impt):  $ cat mylist.txt $HOME/most_impt_dir1 $HOME/most_impt_dir2 $HOME/most_impt_dir3 $HOME/misc $HOME/junk   ...I want to find the most impt dir owned by this user.   Here's what I'm trying:  for i in `cat mylist.txt` do    if [[ -O $i ]] &amp;&amp; [[ -d $i ]]; then     echo "found it: $i"     break   else     echo "$i is not it."   fi  done   The above code does not work for anything in my list because it is literally checking for dirs beginning with $HOME. How do I get my code to use the value of the user's $HOME variable?
93336
Let's say you have directories /dir1 and /dir2/linked, where the latter is a symlink to the former.   When you cd to linked and pwd, you get the output /dir2/linked. If you then cd .., you'll be put on /dir2. This behaviour is consistent with the concept of you being in /dir2/linked before. However, as I understand it, the parent directory (..) of any directory is stored in the directory inode (i.e.:physically in the disk). Obviously,  since /dir2/linked is really /dir1, the parent directory on the inode must be /  To further complicate matters, while inside /dir2/linked, the outputs of ls .. and cd .. ; ls . are different! It seems like cd honors the symlinked path, while ls honors the "physical" path. As mentioned in , there's cd -P for this use case, though.  man pwd mentions "physical" and "logical" working directories, but I still have a few questions at this point:   Is this behaviour always provided by the PWD environment variable, as mentioned in man pwd? Why do default cd and ls have different behaviours, if they're both shell commands (i.e.: not programs)? Does the typical program (not shell command) use PWD instead of the physical path? I realize it's up to the implementation, but is there any rule of thumb?
96547
I would like to take the output of a which command, and cd to the parent directory. For example, say I have the following:  which someprogram   With output:  /home/me/somedirectory/someprogram   And I would like to cd to the directory that someprogram lives in:  cd /home/me/somedirectory   I'd like to accomplish this in one line. What is the most elegant, tricky, short way to do this?
35461
I'd like to write something like this:  $ ls **.py   in order to get all .py filenames, recursively walking a directory hierarchy.  Even if there are .py files to find, the shell (bash) gives this output:  ls: cannot access **.py: No such file or directory   Any way to do what I want?  EDIT: I'd like to specify that I'm not interested in the specific case of ls, but the question is about the glob syntax.
53432
I am trying to look for all XML files in a particular directory and all sub-directories (recursively) inside it.  ls -R *.xml is only listing files in the current directory. I am quite sure, the sub-folders themselves have several .xml files, but none are showing up.  Is this a configuration issue?
62058
I have a directory that contains thousands of files, some of them are hidden.  The command ls -a list all files, including hidden ones, but I need just to list hidden files.  What command should I use?
57967
I'm using Ubuntu 14.04 LTS a little while and I consider myself a beginner.  I am using the Nautilus file manager:    I wonder if you can navigate the folders through the directory tree, like in Windows through folders or the + sign.
65129
help  displays information about builtin commands. What is the source of help? Does it maintain a database for builtin commands, or does it read some files of each builtin commands (similar to the manpage of each utilities)?  Sometimes I find its information seems to expand that by --help  $ cd --help bash: cd: --: invalid option cd: usage: cd [-L|[-P [-e]]] [dir]  $ help cd cd: cd [-L|[-P [-e]]] [dir]     Change the shell working directory.      Change the current directory to DIR.  The default DIR is the value of the     HOME shell variable.      The variable CDPATH defines the search path for the directory containing     DIR.  Alternative directory names in CDPATH are separated by a colon (:).     A null directory name is the same as the current directory.  If DIR begins     with a slash (/), then CDPATH is not used.      If the directory is not found, and the shell option `cdable_vars' is set,     the word is assumed to be  a variable name.  If that variable has a value,     its value is used for DIR.      Options:         -L  force symbolic links to be followed         -P  use the physical directory structure without following symbolic         links         -e  if the -P option is supplied, and the current working directory         cannot be determined successfully, exit with a non-zero status      The default is to follow symbolic links, as if `-L' were specified.      Exit Status:     Returns 0 if the directory is changed, and if $PWD is set successfully when     -P is used; non-zero otherwise.   I thought help extract the help part of the executable, but for a  python script , it isn't  $ help ./pdf-merge.py bash: help: no help topics match `./pdf-merge.py'.  Try `help help' or `man -k ./pdf-merge.py' or `info ./pdf-merge.py'.  $ ./pdf-merge.py --help usage: pdf-merge.py [-h] [-v] [--ask] [--output OUTPUT] [--title TITLE]                     [--author AUTHOR] [--keyword KEYWORD] [--pdftk PDFTK]                     [--gs GS] [--pdfmarks PDFMARKS] [--unicode]                     PDF [PDF ...]  Merge PDFs preserving bookmarks. Thanks to Larry Cai for suggesting that Unicode be supported and for discussion about the `--pdfmarks` option.  positional arguments:   PDF                  an input PDF to merge  optional arguments:   -h, --help           show this help message and exit   -v, --version        show program's version number and exit   --ask                pause for manual pdfmark tweaking   --output OUTPUT      name of the output PDF   --title TITLE        title of output PDF   --author AUTHOR      author of output PDF   --keyword KEYWORD    keywords for the output PDF   --pdftk PDFTK        path to the pdftk executable   --gs GS              path to the gs (Ghostscript) executable   --pdfmarks PDFMARKS  path to pdfmarks file. If not given, a temporary file                        is used. If given and the file is missing, execution                        will stop after the file is created (before the                        Ghostscript run). If given and the file exists, no                        attempt will be make to use pdftk to generate the mark                        file (I assume your input file is what you want).   --unicode            instead of merging PDFs, convert PDF-formatted unicode                        strings. For example `--unicode '&lt;FEFF03B103B203B3&gt;'                        \u03b1\u03b2\u03b3`