How to Use the Ls Command on Linux or Mac OS X to Sort Files based on Second in the Timestamp
Here is the one liner. ls -lhtTr It will output something like total 24152 -rw-rw-r-- 1 sean staff 1.0M May 4 14:31:42 2019 4c2caf52cb084ea39a6a65a0e68ee382 -rw-rw-r-- 1 sean staff 1.0M May 4 14:31:44 2019 76eeeea5d...
Written by Sean Behan on 05/04/2019
How to Use the Ls Command on Linux or Mac OS X to Sort Files based on Second in the Timestamp
Here is the one liner. ls -lhtTr It will output something like total 24152 -rw-rw-r-- 1 sean staff 1.0M May 4 14:31:42 2019 4c2caf52cb084ea39a6a65a0e68ee382 -rw-rw-r-- 1 sean staff 1.0M May 4 14:31:44 2019 76eeeea5d...
Written by Sean Behan on 05/04/2019
How to Time Piped *nix Commands
If you want to time how long a piped bash command take, use the `time` command followed by your commands in parens like so.. time (ls -lha | wc -l)
Written by Sean Behan on 12/11/2017
How to Import/Export a Database from One Heroku App to Another Heroku App
Heroku is awesome! Let's say we want to copy a production database to a staging database. We can use the `pg:backups:restore` command to accomplish this. Here is an example. For the source database we are using the `production-app-name` and for stagi...
Written by Sean Behan on 03/07/2017
Linux Disk Usage Command Recursive
It's short and sweet! du -hs * If you run this command it will tell you the sizes of all the files and folder in the current directory. The `-h` flag is for human readable format and the `-s` will give you the size for each file or directory. ...
Written by Sean Behan on 03/07/2017
How To Create a Dump File in Postgres Compatible with Heroku
When Heroku creates a dump file of your Postgres database it uses the `-Fc` option It is equivalent to running pg_dump -Fc -d name_of_db > name_of_db.dump This command will let you import your database with the `pg_restore` command pg_rest...
Written by Sean Behan on 03/06/2017
How to Fix Pypi Upload failed (403): Invalid or non-existent authentication information.
If you run into authentication failure when trying to upload packages Submitting dist/ to https://upload.pypi.org/legacy/ Upload failed (403): Invalid or non-existent authentication information. error: Upload failed (403): Invalid or non-existent...
Written by Sean Behan on 03/02/2017
Find a File On Your File System with the Unix Find Command By Extension
find path/ -name *.txt
Written by Sean Behan on 11/05/2013
A Couple of Usefule Snippets When Working with Textmate
Here is the snippet f path/to/directory 'search string' | open_in_mate This snippet (technically 2 snippets) will recursively scan the contents of files in a directory and then open all the files it finds in Textmate. It's useful on large projec...
Written by Sean Behan on 10/18/2013
How To Pipe To A Ruby Command Line Application
You need to read from STDIN rather than parse command line arguments. while $stdin.gets puts $_ end
Written by Sean Behan on 10/17/2013
How to Split a Large File Into Smaller Files on OSX or Unix
Use the split command. split -l 1000 name-of-file output/directory You can set the number of lines (the "-l" flag) to split on and also the location of where the split files should be saved. Note, the output directory must already exists....
Written by Sean Behan on 10/08/2013
Using Grep To Find or Match All Links in an HTML Document
egrep -or "(http(s)?://){1}[^'\"]+" path/to/directory You can further reduce to just return the images by piping again. grep -r src views/ | egrep -o "(mailto|ftp|http(s)?://){1}[^'\"]+" The -r flag is for a recursive directory scan....
Written by Sean Behan on 09/15/2013
Recursively Search Contents of a File with Grep
The -r flag is for recursive, meaning it will also look in sub directories. The -i flag is for case insensitivity, meaning WORD and word will both be found. grep -ir "search term" directory/path
Written by Sean Behan on 08/29/2013
How To Create Blurry Background Images Programmatically from the Command Line or with Ruby
Turn this into this You can use ImageMagick to make blurry images. To install with Homebrew on OS X. brew install imagemagick After installing you can run from the command line convert yourimage.png -channel RGBA -blu...
Written by Sean Behan on 08/24/2013
How Many Gigs of RAM Are On My Server?
How much memory is on my linux server? Run the free command free -g total used free shared buffers cached Mem: 2 1 0 0 0 1 -/+ buffers/cache: 0 1 Swap: ...
Written by Sean Behan on 06/17/2012
Uncompress A Bz2 File Using Tar Command
Uncompress a bz2 file using tar command tar --use-compress-program bzip2 -xvf your-file-to-uncompress.tar.bz2 @source http://www.kde.gr.jp/help/doc/kdebase/doc/khelpcenter/faq/HTML/bzip2.html...
Written by Sean Behan on 06/17/2012
Launch Photoshop (Or Any App) From The Command Line on Mac OS X
I often find myself coding with the terminal open. Cding around a web app project I usually end up at some point launching Photoshop. Either to touch up or work on a psd, png, jpg ...etc. I fire up Photoshop and then navigate to the app's public directory...
Written by Sean Behan on 06/17/2012
Recursively Zip a Directory and Files on Linux
It's Short and sweet! Just remember that the finished zip filename is the first argument and the directory you wish to recursively zip comes after. zip -r name_of_your_directory.zip name_of_your_directory That's all. You might be intere...
Written by Sean Behan on 03/05/2017
Add Users to a Group on Ubuntu
To create a new user on Ubuntu (Heron8) adduser johndoe To create a new group groupadd barleyfarmers Add johndoe to the barleyfarmers group adduser johndoe barleyfarmers The adduser command, when you're first adding the new user accou...
Written by Sean Behan on 03/02/2017