Can the Unix list command ‘ls’ output numerical chmod permissions?
it almost can .. ls -l | awk ‘{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/) \ *2^(8-i));if(k)printf(“%0o “,k);print}’
it almost can .. ls -l | awk ‘{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/) \ *2^(8-i));if(k)printf(“%0o “,k);print}’
Piping to another process (Although this WON’T accomplish what you said you are trying to do): command1 | command2 This will send the output of command1 as the input of command2 -exec on a find (this will do what you are wanting to do — but is specific to find) find . -name ‘*.foo’ -exec … Read more
Try this ls -d */ to list directories within the current directory
tar in itself just bundles files together (the result is called a tarball), while zip applies compression as well. Usually you use gzip along with tar to compress the resulting tarball, thus achieving similar results as with zip. For reasonably large archives there are important differences though. A zip archive is a collection of compressed … Read more
I’m going to assume you mean carriage returns (CR, “\r”, 0x0d) at the ends of lines rather than just blindly within a file (you may have them in the middle of strings for all I know). Using this test file with a CR at the end of the first line only: $ cat infile hello … Read more
I’d recommend pygmentize from the python package python-pygments. You may want to define the following handy alias (unless you use ccat from the ccrypt package). alias ccat=”pygmentize -g” And if you want line numbers: alias ccat=”pygmentize -g -O style=colorful,linenos=1″ Add one of these above commands to ~/.bash_aliases for permanent effect
I think you’ll get what you want with the -maxdepth 1 option, based on your current command structure. If not, you can try looking at the man page for find. Relevant entry (for convenience’s sake): -maxdepth levels Descend at most levels (a non-negative integer) levels of direc- tories below the command line arguments. `-maxdepth 0′ … Read more
You can use the option -C (or –directory if you prefer long options) to give the target directory of your choice in case you are using the Gnu version of tar. The directory should exist: mkdir foo tar -xzf bar.tar.gz -C foo If you are not using a tar capable of extracting to a specific … Read more
In Linux or MacOS you can use: date +%s where +%s, seconds since 1970-01-01 00:00:00 UTC. (GNU Coreutils 8.24 Date manual) Example output now 1454000043.
If you want to delete lines from 5 through 10 and line 12th: sed -e ‘5,10d;12d’ file This will print the results to the screen. If you want to save the results to the same file: sed -i.bak -e ‘5,10d;12d’ file This will store the unmodified file as file.bak, and delete the given lines. Note: … Read more