PS1

Make your shell prompt useful:

PS1="-----------------------------------------------------------------------\n\u@\W:"

Posted in Uncategorized | Leave a comment

Spell

Check for spelling errors in the Constitution of the United States of America

spell cotus.txt | sort | uniq

Posted in Uncategorized | Leave a comment

Which

Find where your stuff is

 

Posted in Uncategorized | Leave a comment

Split

Split a large text file into pieces with 10,000 lines each:

split -l 10000 starostin-all.txt

Posted in Uncategorized | Leave a comment

Httrack

Mirror a website on your hard drive:

Copy all the html files from your local mirror of a website to a single directory:

find . -name "*.html" -exec cp {} /home/teresita/Desktop/html \;

Convert all the html files in a directory to text:

for i in *.html; do lynx --dump "$i" > "${i%%.*}.txt";done

Posted in Uncategorized | Leave a comment

Rot13

Rot13 “cipher” in #Python

#!/usr/bin/python3
import sys, string
def rot13(s):
return ''.join([chr(x.islower() and ((ord(x) - 84) % 26) + 97
or x.isupper() and ((ord(x) - 52) % 26) + 65
or ord(x))
for x in s])
for line in sys.stdin:
sys.stdout.write(rot13(line))

Posted in Uncategorized | Leave a comment

RTF

#LibreOffice

Bulk convert RTF files to PDF:

libreoffice –convert-to pdf *.rtf

Posted in Uncategorized | Leave a comment

Seq

The sum and product of the first 100 integers:

seq -s "+" 1 100 | bc
seq -s "*" 1 100 | bc

 

Posted in Uncategorized | Leave a comment

Dir

dir –color=always

Posted in Uncategorized | Leave a comment

Nl

Add line numbers to a file (Four digits, leading zeros, separated by a colon):

nl -i1 -s': ' -nrz -w4 cotus.txt

awk '{printf"%04d: ",NR;print}' cotus.txt

Oh wait, you don’t want to count the blank lines?

awk '/[^ ]/{printf"%04d: ",++n}{print}' cotus.txt

Oh wait, you only want the first 30 lines?

awk '/[^ ]/{printf"%04d: ",++n}{print}NR==30{exit}' cotus.txt

Posted in Uncategorized | Leave a comment