tree and ls can distinct file types by coloring filenames differently.   tree and ls often output a long list of files (including directories), so I pipe the stdout output to less.  But less doesn't preserve the colors. How can we make it show colors, or some alternative ways?  Just saw the linked list, but piping to less -R or less -r doesn't work. My OS is Ubuntu 12.04. less is Version 444: 09 Jun 2011.
121655
I get colored tree using tree -C but when I pipe it to less I get results like this:  tree public/ -C | less     How can I have colors in less in this case?
73988
Everybody knows :-) that in Windows plain text files lines are terminated with CR+LF, and in Unix&amp;Linux - with LF only. How can I quickly convert all my source code files from one format to another and back?
122736
I'm a bit new to bash scripting, and I'm wondering if there is a program or built-in command to pipe to that will print in a specified color? Or is there an echo argument to do so?  Like I could do:  echo Hi | commandhere -arguement blue   and it would print "Hi" in the color blue?
94774
ls returns output in several columns, whereas ls|cat returns byte-identical output with ls -1 for directories I've tried. Still I see ls -1 piped in answers, like ls -1|wc -l. Is there ever a reason to prefer ls -1? Why does ...|cat change the output of ls?
120346
How do I list all files under a directory recursively and sort the output by modification time?  I normally use ls -lhtc but it doesn't find all files recursively. I am using Linux and Mac.  ls -l on Mac OS X can give  -rw-r--r--    1 fsr  user      1928 Mar  1  2011 foo.c -rwx------    1 fsr  user      3509 Feb 25 14:34 bar.c   where the date part isn't consistent or aligned, so a solution have to take this into account.  Partial solution  stat -f "%m%t%Sm %N" ./* | sort -rn | head -3 | cut -f2-   works, but not recursively.
96588
I came up with the following snippet for counting files in each subdirectory:  for x (**/*(/)); do print $x; find $x -maxdepth 1 -type f | wc -l; done   The command outputs consecutive pairs (one below the other) as follows:  directory_name # of files   I would like to change the code above to:   Print each match on the same line (i.e. directory_name ':' # of files) Only count files if the folders are leaves in the directory tree (i.e. they don't have any subfolders).    How can I do that?
50656
I am working on some C++ files all of which are in a single folder.   When I do ls both the .cpp and the .h files show up in the same colour.   Is there a way to tell the bash shell that I want to display .cpp files in pink and .h files in golden-brown?
114623
Up until recently I was under the impression that Unix-y programs were unaware of where their output went, be it to standard out, redirected to a file, or into a pipe. However, an unrelated U&amp;L question on this site brought to my attention the following example:  % echo "hello world" &gt; file  % grep --color=auto lo file hello world  % grep --color=auto lo file | cat hello world   Obviously you can't see it here, but the first command shows 'lo' highlighted, as expected. However, the second call, which goes through a pipe, shows no colour. This suggests that grep was aware of its output being directed to a pipe and avoided outputting colour. How is this done?
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
63991
I was able to do a tail -f output with colors using the awk command. But I'm unsure how to output the rest of the log as it seems to be filtering only those 2 lines. I also want to see the other lines as the log is written.  What do I need to put in the awk command to show the rest of the output?  Image of my issue. The red text above is without using awk and displays the entire tail -f log. And below that is the same command with the awk color filtering.
100276
I have a command that produces output in color, and I would like to pipe it into a file with the color codes stripped out. Is there a command that works like cat except that it strips color codes? I plan to do something like this:  $ command-that-produces-colored-output | stripcolorcodes &gt; outfile
80255
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 avoid this parsing, but similarly, find mydir | wc -l will break for the same reasons.  I'm working on Solaris right now, but I'm looking for a answer as portable across different unices and different shells as possible.
35812
I run a script in terminal and the output printed in the terminal I also save in a text file. How can I display that text in Gedit colored similar to what I can see in the terminal? I thought there could be a plugin. Update I might not have been as clear as I planed, so I would like to see similar coloring changes in the plain text file as appears in terminal, not for shell scripts but if I have an error message (e.g. compiler error) than those line to be differentiated from other printouts in terminal. $ rosrun my_pkg my_node &gt;&gt; terminal_printout Update 2 My gedit version is 3.10.4 ii  libgtksourceview-3.0-1:amd64   3.10.2-0ubuntu1 amd64 sared libraries for the GTK+ syntax highlighting widget ii  libgtksourceview-3.0-common    3.10.2-0ubuntu1 all common files for the GTK+ syntax highlighting widget
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?
2083
ls option --group-directories-first causes directories to be listed on the top, which makes the output of ls nice and clean:  ls -l --group-directories-first   However, it does not act on symlinks, which are actually symlinks to directories. There is a possibility to use   ls -l -L --group-directories-first   which will list both kind of directories on top, but will not distinguish between proper directory and symlinked directory, which is again confusing.  Can ls display symlinked directories on top, while still keeping them distinct from regular directories?  EDIT: I am using bash.
28628
For example,   Say I want to list the contents of a folder and directly paste them into a chat window for a friend to see.    I realize I could do ls &gt; filename.txt to create a file (filename.txt) with those contents; I'd then have to open or print the file and manually select and copy the text block (which can be annoying/tedious.)  I clearly could also select and copy the output of ls directly from within the terminal window.  It would be much faster/easier to simply pipe standard output to the clipboard.  What terminal command allows me to do this?
122179
When I need to find my recently used files, this command:  ls -lt  lists in ascending order (by time), when there are lots files, I need to scroll to the top to see needed files, because won't fit in terminal screen.  After finding out that tac inverses the output, I use: ls -lt dir/ | tac Is there more fun way of doing it, without using external scripts/utils?