This command will list 20 of the most recently modified files in a directory.
jason@Yog-Sothoth:~/Documents$ ls -thor | head -n 20 total 3.9G -rwxrwxrwx 1 jason 219K Mar 20 2008 northwind.sql -rw------- 1 jason 2.2M Jan 21 2009 ubuntupocketguide-v1-1.pdf -rwxrwxrwx 1 jason 1.9K Apr 28 2011 randimg.c -rw-r--rw- 1 jason 18K Feb 16 2013 netinstall -rwxrwxrwx 1 jason 458 Oct 12 2013 loop.cpp -rwxrwxrwx 1 jason 62 Oct 13 2013 hello.c -rwxrwxrwx 1 jason 477K Oct 14 2013 registration.js -rwxrwxrwx 1 jason 417 Oct 25 2013 setup-ad-server.ps1 -rwxrwxrwx 1 jason 57K Oct 26 2013 hell.png drwxrwxrwx+ 2 jason 4.0K Dec 24 2013 PHP -rwxrwxrwx 1 jason 705 Jan 28 2014 employees.java -rw------- 1 jason 1.7K Feb 21 2015 ServerWOPR.pem -rw-r--rw- 1 jason 302K Jun 13 2015 1434065177594.jpg -rw-r--rw- 1 jason 213K Jun 13 2015 1434065201125.jpg -rw-r--rw- 1 jason 219K Jun 13 2015 1434065287849.jpg -rw-r--rw- 1 jason 283K Jun 13 2015 1434065333771.jpg -rw-r--rw- 1 jason 115K Jun 13 2015 1434065384104.jpg -rw-r--rw- 1 jason 106K Jun 13 2015 1434065359757.jpg -rw-r--r-- 1 jason 1.4M Feb 23 2016 RAIDInteractiveSimulator4.exe |
Print all lines in a text file betwixt line 10 and line 20.
jason@Yog-Sothoth:~/Documents$ awk 'NR>=10&&NR<=20; BEGIN {print $1}' hands.txt Graphic Addon Only : No Dehack Patch Only : No .LMP Only : No Other : No * Play Information * Map # : E1M1 Single Player : Yes Cooperative 2-4 Player : Yes Deathmatch 2-4 Player : Starts present. |
Your top 10 most used Linux commands in your .bash_history file.
jason@Yog-Sothoth:~/Documents$ history | awk '{ print $2 }' | sort | uniq -c |sort -rn | head 111 sudo 51 ls 49 cd 39 mc 24 history 23 date 20 awk 15 find 14 cmake 8 youtube-dl |
Find all instances of the word “doom2” in all files in directories recursively in a folder in your Linux installation.
4.4 Thu Dec 05 jason@Yog-Sothoth 1: $ grep -Rine "Doom2" .config/gzdoom/gzdoom.ini:52:# but files listed under 'doom.doom2.Autoload' will only load when you are .config/gzdoom/gzdoom.ini:53:# playing a Doom 2 based game (doom2.wad, tnt.wad or plutonia.wad), and files listed under .config/gzdoom/gzdoom.ini:54:# 'doom.doom2.commercial.Autoload' only when playing doom2.wad. .config/gzdoom/gzdoom.ini:58:[doom.doom2.Autoload] .config/gzdoom/gzdoom.ini:60:[doom.doom2.commercial.Autoload] .config/gzdoom/gzdoom.ini:62:[doom.doom2.bfg.Autoload] .config/gzdoom/gzdoom.ini:64:[doom.doom2.plutonia.Autoload] .config/gzdoom/gzdoom.ini:66:[doom.doom2.tnt.Autoload] .config/gzdoom/gzdoom.ini:74:[doom.doom2.wadsmoosh.Autoload] .config/zandronum/zandronum.ini:46:# but files listed under Doom2.Autoload will only load when you are .config/zandronum/zandronum.ini:53:[Doom2.Autoload] grep: .config/chromium/SingletonSocket: No such file or directory grep: .config/chromium/SingletonLock: No such file or directory grep: .config/chromium/SingletonCookie: No such file or directory ^C |
How to only show a certain column in a CSV file. This is very easy to do. Just use the csvtool program.
Install the utility.
4.4 Sun Dec 22 jason@Yog-Sothoth 2: $ sudo apt install csvtool |
Then run it like this to get only the 16th column in the file.
4.4 Sun Dec 22 jason@Yog-Sothoth 2: $ csvtool format '%(16)\n' FL_insurance_sample.csv | head -n 20 line Residential Residential Residential Residential Residential Residential Commercial Residential Residential Residential Residential Residential Residential Residential Residential Residential Residential Residential Residential |
This is very useful when working with a very large CSV file, and you only need a certain value.