Very interesting and strange bash trick with ls.

This is a very interesting bash trick I found using ls. This runs the ls command with random parameters. This is not very useful, but interesting nonetheless. 4.4 Tue Mar 03 jason@Yog-Sothoth 0: $ ls -`cat /dev/urandom | tr -dc ‘hula’ | head –bytes 1`4.4 Tue Mar 03 jason@Yog-Sothoth 0:…

Read More

How to sort the output of ls by date modified.

Sorting the output of ls by date modified is very easy. This is how to sort output and display the few most recent files. This example shows how to do this. Use head – 20 to list only the top 20 results. 4.4 Tue May 21 jason@Yog-Sothoth 0: $ ls…

Read More

How to list only directories with the ls command on Mac OSX.

The ls command on Mac OSX works a little differently than on a Linux machine, but listing only directories is very simple. This is one example, using only the ls command. deusexmachina:Documents jason$ ls -ld — */ drwxr-xr-x 3 jason staff 102 5 Mar 2018 POL/ drwxrwxrwx 31 jason staff…

Read More

An alternative to the ls command to print a directory listing.

This is a good alternative to the ls command to print a directory listing. This is very useful for quickly viewing the contents of a directory. ┌─[jason@parrot]─[~/Documents] └──╼ $find ./ -printf "%f\n" ./ password-01.kismet.netxml password-01.cap read.c out.xml netcomm.txt a.out password-01.kismet.csv rockyou.txt password-01.csv mysql.txt notify.js┌─[jason@parrot]─[~/Documents] └──╼ $find ./ -printf "%f\n" ./…

Read More

Useful Linux/UNIX commands.

Using wild-cards to display various files in a folder with ls. I recently needed to check whether certain files were in the /usr/lib folder and I used the ls command to do this. to find all files related to the Perl programming language in the /usr/lib directory. ubuntu ~ $…

Read More

Some useful tips for listing directories with ls on Linux.

To list the contents of a directory with the listing sorted by size, use the parameters in this example. ls –format=long –sort=size -hls –format=long –sort=size -h This is what you will get. total 15G -rw-rw-r– 1 ubuntu ubuntu 15G Dec 2 2014 crackstation.txt -rw-rw-r– 1 ubuntu ubuntu 20M Mar 20…

Read More

Use ls to only list files that start with an uppercase character.

The ls command may be used in conjunction with grep to list files that start with an uppercase letter or have an uppercase filename. ┌──(john㉿DESKTOP-PF01IEE)-[~/Documents] └─$ ls | grep "^[A-Z]" Boomsrc Hope is the good thing(The Shawshank Redemption 1994). [JAmspaaSNzE].f140.m4a Hope is the good thing(The Shawshank Redemption 1994). [JAmspaaSNzE].f160.mp4 Hope…

Read More

List files by modification date with the ls command on Linux.

This one-liner will list all files in a directory by modification time, newest first. jason@eyjafjallajkull:~/Pictures$ ls -thuljason@eyjafjallajkull:~/Pictures$ ls -thul Use it this way to list the top 20 files listed. jason@eyjafjallajkull:/var/log$ ls -thul | head -n 20 total 6.9M -rw-rw-r– 1 root utmp 9.0K Jul 9 11:30 wtmp -rw-r–r– 1…

Read More

Some miscellaneous BASH tricks. Useful tips for all Linux users.

This command shows how to display a listing of files with ls and show line numbers at the same time. homer@deep-thought ~/Desktop/Site % ls | nl 1 back.jpg 2 bejiitas_phpb1 3 bejiitas_phpb1.sql 4 cgi-bin 5 Files.tar.lzma 6 Map07Tufb.zip 7 my2.tar.lzma 8 program.c 9 quake38.jpg 10 sysinfo 11 tekcrazy_2.zip 12 wrap.rarhomer@deep-thought…

Read More

More awesome shell tricks for the Linux command line. This is using the bash shell.

This is another way to see where you are in the directory stack. homer@deep-thought ~/Documents/basenew $ echo $DIRSTACK ~/Documents/basenewhomer@deep-thought ~/Documents/basenew $ echo $DIRSTACK ~/Documents/basenew Here is another way to show the $PWD value one directory down from where you are now. homer@deep-thought ~/Documents/basenew $ echo $OLDPWD /home/homer/Documentshomer@deep-thought ~/Documents/basenew $ echo…

Read More

How to filter text with the sed command. This is useful for various shell tricks.

Using wildcards on the Linux command line This is a standard listing of files with wildcards in the bash shell. homer@deep-thought ~/Documents $ ls *.wad basenew.wad cc4-tex.wad city-heat.wad dark.wad doom.wad plutonia.wad scythe2.wad SKYTEST.wad brick.wad cchest4.wad consoleCopy.wad doom2.wad hexen.wad RIII.wad scythex.wad SODfinal.wadhomer@deep-thought ~/Documents $ ls *.wad basenew.wad cc4-tex.wad city-heat.wad dark.wad doom.wad…

Read More