GithubHelp home page GithubHelp logo

command-line-snippets's Introduction

command-line-snippets

The following is a collection of useful command line snippets that I use regularly.

PDF modification

Merge multiple PDF files
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=full.pdf page1.pdf page2.pdf page3.pdf
Split a multipage PDF file
gs -sDEVICE=pdfwrite -dSAFER -o p%d.pdf multipage.pdf
Extract pages from a PDF file
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=1 -dLastPage=12 -sOutputFile=outfile_p1-p12.pdf original_input.pdf
Trim PDF margins
pdfjam –suffix out –trim '6.5cm 4.5cm 6.5cm 4.5cm' – source.pdf

Text edition

Insert a header at the top of a text file

sed -i -e "1i Here\nIs\nMy\nHeader\n" file.txt

File management

Delete all files that end with tilde

find . -type f -name '*~' -exec rm -f '{}' \;

Find duplicate files (asking for deletion)

fdupes -r ~/dir1 ~/dir2 -d

Recursively rename all file extensions to lower case

find . -type f | sed 's/\(.*\/\)\(.*\)/mv "\1\2" "\1\L\2"/' |sh

Software development

Search all .java files for a string

find . -name "*.java" -print | xargs grep "exampleOfString"

Release with Maven

mvn clean
mvn release:prepare -Darguments=-Dgpg.passphrase="My\ passphrase"
mvn release:perform -Darguments=""

Network

Change a network interface MAC address
ifconfig wlan0 down
macchanger -A wlan0
ifconfig wlan0 up
Measure TCP bandwidth performance
# On server station (ip=192.168.1.10)
iperf -s -f m
# On client station
iperf -c 192.168.1.10 -f m

Photos

Adjust time stored in the EXIF data by 30 minutes forward for all .jpg files
jhead -ta+0:30 *.jpg
Rename all .jpg photos to <date>_<time>.jpg (with date & time from EXIF data)
exiv2 rename *.jpg

Video

Convert .ogv files to .avi files
mencoder movie.ogv -ovc xvid -oac mp3lame -xvidencopts pass=1 -o movie.avi
Convert AVCHD (.mts) files to .avi files
ffmpeg -i movie.mts -vcodec libx264 -crf 23 -acodec libmp3lame -ac 2 -ab 192k -s 640x360 movie.avi
Play a movie in ASCII art
mplayer -vo caca movie.avi

Web

Download all pdfs from given url
wget -r -A '*.pdf' url/path

Pro

Pulse Secure connection/disconnection
# Pulse Secure connection
"/path/to/Pulse Secure/Integration/pulselauncher.exe" -url "https://a.pulse.secure/url" -u "a_username" -p "a_password" -r "DOMAIN"
# Pulse Secure disconnection
"/path/to/Pulse Secure/Integration/pulselauncher.exe" -signout -url "https://a.pulse.secure/url"

Miscellaneous

Send a command to a serial/USB port
echo -ne '\xaa\xbb\x06\x00\xff\xff\x06\x01\x64\x63' > /dev/ttyUSB0
Sniff a serial/USB port
apt-get install jpnevulator
jpnevulator --ascii --timing-print --tty "/dev/ttyUSB0" --read
Generate a random number between 1024 and 4096
shuf -i 1024-4096 -n 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.