Last active
March 27, 2017 01:13
-
-
Save swaroopjcse/003e33dce1133906815a to your computer and use it in GitHub Desktop.
Some Unix utilities I use from time to time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################## | |
# Author: Swaroop Joshi # | |
# Last modified: 2017-03-26 # | |
# These commands work on the fish shell on my Mac OS X Yosemite. # | |
# Other shells/versions may require some modification # | |
################################################################## | |
# Upper to lower | |
tr '[:upper:]' '[:lower:]' | |
# Remove duplicate lines | |
awk '!x[$0]++' | |
# Sort | |
sort | |
# Swap columns | |
awk '{print $2, $1}' | |
#-or- | |
awk -F, 'BEGIN{OFS=FS;}{t=$i;$i=$j;$j=t;}1' i=1 j=2 file | |
# append a new line at the beginning of each file in the directory | |
for file in *; sed '1i\ | |
new first line\ | |
\ | |
' $file > {$file}.1; mv {$file}.1 $file; | |
end | |
# Compare two files and show lines in one file that are not in the other | |
grep -F -x -v -f fileB fileA | |
# Extract pages from a pdf and create a new pdf | |
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \ | |
-dFirstPage=10 -dLastPage=36 -sOutputFile=out.pdf in.pdf | |
# Better way of achieving the above? | |
pdfjam in.pdf '10-36' -o out.pdf | |
# Convert a pdf to 2-column one | |
pdfjam -o out.pdf in.pdf '9-19' --nup 2x1 --landscape | |
# Printing from CSE system | |
lpr <file> -o number-up=2 -o sides=two-sided-short-edge -P lj_cl_413 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment