in a Terminal session the command   ls *.pdf -l   does not list the pdfs (or whatever other file format) as expected, as the -l option seems to be ignored. Everything works fine if I issue a simple  ls -l   How do I fix this?  I'm on Mac OS X 10.7.5 and using a bash shell.
120767
The command  shell$ ls . -R    works on Linux but not on OS X. This is because OS X command line options have to come before  the arguments,and not just anywhere as in Linux.   In particular, this means that any shell scripts I write on Linux will be unportable to Macs.    Question  How can I fix this on the Mac?   I can either take care to write portable Linux scripts, or I can install MacPorts so that  ls  and other commands will be picked from MacPorts and not the Apple provided binaries. Is there any better way?
28570
In my .emacs I have  '(TeX-PDF-mode t)    set. So I'm using PDFLaTeX. I'm not sure why this is not the default these days. I had also set  '(LaTeX-command "latex -shell-escape")   In hindsight this was a bad idea, but I didn't realise it till  I was trying to get SyncTeX to work, but it wouldn't. I belatedly realized that because I had set LaTeX-command manually, I was overwriting the   --synctex=1   option that would normally have been there.  Which brings to my question.   Is LaTeX-command the right command to modify to add the -shell-escape option, and if so What is the right way to add an option to LaTeX-command?   @David Carlisle suggested   (setq LaTeX-command (concat LaTeX-command " -shell-escape"))   which seems to be in the right ballpark, but this gives the error:   Symbol's value as variable is void: LaTeX-command   NOTE: Evaluating LaTeX-command just gives "latex", so this may not be the right thing to append to.
91419
I'm trying to tidy-up my photos which are, for various historic reasons, scattered all over my system. To enable me to make a start on this task, I've been trying to use the command line to construct a list of all directories that contain one or more jpg files.  I'm certain that I don't have to be concerned about looking for other image file formats, but I do have to allow for jpg appearing in upper and lower case.  I'd like each directory name to appear only once in the final list.  To provide an example, if I have the following directories each of which contain one or more jpg or JPG files....  ~Mike/Pictures ~Mike/Pictures/London/Olympics ~Mike/Pictures/London ~Mike/Pictures/London/Holiday ~Mike/Photos ~Mike/Family History/Swaine   I'd like the results to appear with each directory listed only once - irrespective of the number of image files it might contain - preferably sorted and then written to a file  ~Mike/Family History/Swaine ~Mike/Photos ~Mike/Pictures ~Mike/Pictures/London ~Mike/Pictures/London/Holiday ~Mike/Pictures/London/Olympics   My command line skills are just not up to this!  I can use a lot of the simpler forms of single commands, but once they get complex and/or have to be piped things tend to go wrong.
112793
I am writing a bash script to automate several actions:  #!/bin/bash           echo "Hello, World" NAME="${1}" PATH="${2}" echo $NAME echo $PATH eval "ls"   I am going to call ls, ffmpeg and a lot of other commands.  However running my script gives me the following error:  /var/www/html# ./life.sh test midhand.mp4 + ./life.sh test midhand.mp4 Hello, World test midhand.mp4 ./life.sh: line 9: ls: command not found   How come? why not found? Maybe I should import a directory with scripts?
115653
When I execute a command from a terminal that prints coloured output (such as ls or gcc), the coloured output is printed. From my understanding, the process is actually outputting , and the terminal formats the colour.  However, if I execute the same command by another process (say a custom C application) and redirect the output to the application's own output, these colours do not persist.  How does a program decide whether or not to output text with colour format? Is there some environment variable?
2420
What do the different colours in Ubuntu's ls command mean? For example, when I type the ls command in one of my folders, I get one of the files in light green, the other (which is a folder) in blue with green highlighting.   What do those colours mean, and there is any manual about all the colours?
64487
OS X terminal is not using colors for highlighting output from different commands, for example ls.   When compared with other systems like Ubuntu, this is a big loss of accessibility/productivity.  What solutions do I have to improve this experience? For the moment I found only this guide for  but I am looking for a more complete solution.
12419
I'd tried command cat with an executable file:  cat /bin/ls   Now I can't read any word in this terminal (Linux console). How can I fix it?
5744
I think I may be overlooking a relatively fundamental point regarding shell. Output from the ls command by default separates output with newlines, but the shell displays the output on a single line.  Can anyone explain this to me? I had always presumed that the output was simply separated by spaces, but now that I see the output separated by newlines, I would expect the output to be displaying on separate lines.  Example:  cpoweradm@debian:~/lpi103-4$ ls text* text1  text2  text3   od shows that the output is separated by newlines:  cpoweradm@debian:~/lpi103-4$ ls text* | od -c 0000000   t   e   x   t   1  \n   t   e   x   t   2  \n   t   e   x   t 0000020   3  \n 0000022   If newlines are present, then why doesn't the output display as:  text1  text2 text3
44735
I have got the directory called Test and a few directories inside it. Both Test and the directories inside it have executable files. I'd like to print them with ls. I'd use this command.  ls -l `find Test/ -perm /u=x,g=x,o=x -type f`   Is this a good/right/quick command or not?  My solution is:  find Test/ -executable -type f -exec ls -l {} \;   and got the same result as warl0ck and pradeepchhetri offered.
74027
Doing "ls" gives me absolutely no response. No "command not found", no "permission denied", absolutely nothing. I'm really confused. Please help.  Info: Running Ubuntu Server 16.04.4 on a Digital Ocean VM, 1 GB, 1 vCPU.
16964
I'm on OSX Snow Leopard.  Here's the full contents of grr.sh:  #!/bin/sh  echo wow   When I try to run it from terminal:  $ grr.sh -bash: grr.sh: command not found $ /bin/sh grr.sh wow $ sh grr.sh wow $ bash grr.sh wow   Okay. Fair enough. I'll give it executable permission, then try again:  $ chmod +x grr.sh $ grr.sh -bash: grr.sh: command not found $ chmod 755 grr.sh $ grr.sh -bash: grr.sh: command not found   Hmmm. Maybe it'll work if I use bash explicitly? I'll change the file's contents to:  #!/bin/bash  echo wow   And I get the exact same results. What could I have broken?!  One last thing! In case you're curious...  $ which sh /bin/sh
6109
I spend most of my time working in Unix environments and using terminal emulators. I try to use color on the command line, because color makes the output more useful and intuitive.  What options exist to add color to my terminal environment? What tricks do you use? What pitfalls have you encountered?  Unfortunately, support for color varies depending on terminal type, OS, TERM setting, utility, buggy implementations, etc.  Here are some tips from my setup, after a lot of experimentation:   I tend to set TERM=xterm-color, which is supported on most hosts (but not all). I work on a number of different hosts, different OS versions, etc. I use everything from macOS X, Ubuntu Linux, RHEL/CentOS/Scientific Linux and FreeBSD. I'm trying to keep things simple and generic, if possible. I do a bunch of work using GNU screen, which adds another layer of fun. Many OSs set things like dircolors and by default, and I don't want to modify this on a hundred different hosts. So I try to stick with the defaults. Instead, I tweak my terminal's color configuration. Use color for some  (ls, grep, less, vim) and the . These commands seem to use the standard "". For example:  alias less='less --RAW-CONTROL-CHARS' export LS_OPTS='--color=auto' alias ls='ls ${LS_OPTS}'    I'll post my .bashrc and answer my own question Jeopardy Style.
62288
This question was prompted by questions about ls' -1 option and the recurring tendency of people to ask question and answers that includes processing the output of ls.   This reuse of the output ls seems understandable, e.g.: if you know how to sort a list of files with ls you might want to use the output in that way as input for something else.  If those Q&amp;A don't include a reference to the file name list produced consisting of nicely behaving file names (no special characters like spaces and newlines), they are often commented upon by someone pointing out the danger of the command sequence not working when there are files with newlines, spaces etc.  find, sort and other utilities solve the problem of communicating "difficult" file names to e.g. xargs by using an option to separate the file names with the NUL character/byte which is not a valid character in file name (the only one in addition to /?) on Unix/Linux filesystems.  I looked to the man page for ls and the output for ls --help (which has more options listed) and could not find that ls (from coreutils) has an option to specify NUL separated output. It does have a -1 option which can be interpreted as "output file names separated by newline")  Q: Is there are technical or philosophical reason why ls does not have a --zero or -0 option that would "output file names separated by NUL"?  If you do something that only outputs the file names (and not use e.g. -l) that could make sense:  ls -rt -0 | xargs -r0 …   I could be missing something why this would not work, or is there an alternative for this example that I overlooked and that is not much more complicated and/or obscure.    Addendum:  Doing ls -lrt -0 probably does not make much sense, but in the same way that find . -ls -print0 does not, so that is not a reason to not provide a -0/-z/--zero option.
14187
Why does $ ls &gt; ls.out cause 'ls.out' to be included in list of names of files in current directory? Why was this chosen to be? Why not otherwise?
70440
I've been studying about the command line and learned that | (pipeline) is meant to redirect the output from a command to the input of another one. So why does the command ls | file doesn't work?  file input is one of more filenames, like file filename1 filename2  ls output is a list of directories and files on a folder, so I thought ls | file was supposed to show the file type of every file on a folder.  When I use it however, the output is:      Usage: file [-bcEhikLlNnprsvz0] [--apple] [--mime-encoding] [--mime-type]         [-e testname] [-F separator] [-f namefile] [-m magicfiles] file ...     file -C [-m magicfiles]     file [--help]   As there was some error with the usage of the file command
2869
I used to work on the Mac terminal before and I used:   open file2open.pdf   and the PDF file would be opened on preview or whatever my default viewer was. When I use it in the terminal in Ubuntu I get this error message:   Couldn't get a file descriptor referring to the console