Skip to content

Instantly share code, notes, and snippets.

@DrJume
Last active October 16, 2018 17:38
Show Gist options
  • Save DrJume/bb1c1138ee4e9e5fee0ad021a14f0954 to your computer and use it in GitHub Desktop.
Save DrJume/bb1c1138ee4e9e5fee0ad021a14f0954 to your computer and use it in GitHub Desktop.
A selection of useful bash commands and shortcuts
One Line FTP server
python -m pyftpdlib --help
Run last command again as sudo
sudo !!
Repeat the last argument of the last argument
ls /home/drjume/test.txt (through TABbing)
nano !$
Put all the arguments from last command into new one
grep NICHTS /home/drjume/test.txt
egrep !:1-$
Remove the last file entry in a path string
nano /home/drjume/test.txt
ls /home/drjume/test.txt:h --> /home/drjume/
List known users
lslogins
Alarm clock leave
leave
Start background process to wait and execute a command
sudo bash -c 'sleep 2h; ./pushover.sh "Server restart" > /dev/null; reboot' &
Go into folder temporarily (like a stack)
pushd <DIR>
popd # Get out
Clear bash input line
<CTRL> + U
Parse json output
cat package.json | jq
Text search in a folder recursively
grep -rni ('.(FOLDER)') -e '<TEXT>'
  • --> USE ACK
File search in a folder recursively
find . -name '\*.xml'
find . -name '\*abc*'
Connect to a serial device
sudo cu -l /dev/tty.usbmodem14202 -s 115200
  • type "~." to disconnect
Copy the newest file from the cwd
cp "$(ls -1t | head -n 1)" /Volumes/MINI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment