ODOC: tr

tr – Translate or Delete characters

Summary :

tr will Translate, squeeze, and/or delete characters from stdin, writing to stdout.

Examples :

$ echo “fslog” | tr “fs” “FS” — Translate f to F & s to S.

$ echo “fslog” | tr “[a-z]” “[A-Z]” — Change case (lower to upper)

$ echo “HelloooOOOoooo” | tr -s ‘[:lower:]’ — Squeez the “lower” case letters.

$ echo “FxSyLzoyg” | tr -d xyz — Remove xyz

$ cat myfile | tr -s ‘n’ — Remove repeated new lines.

$ echo “ABCDEFG” | tr -c “ACEG” “n” — Expect “ACEG” translate others to newline char.

‘tr’ supports few std esc sequences, regular expressions, char classes
(lower, upper, space, blank, alpha,…), etc.

Read : man tr

Tech Tags: linux

ODOC: more

more — File perusal filter for crt viewing

Summary :

Perusal means the act of reading, especially of reading through or with care. More is a filter for paging through text one screenful at a time.

Examples :

$ more myfile1 myfile2 — Show myfile 1 & 2 page by page.

$ more -10 myfile — Show 10lines/page.

$ more -d myfile — Usually more show % of viewed content only at the bottom. With -d it shows more verbose prompt.

$ more -p -10 myfile — Don’t scroll the output. Just the screen and display the text.

$ more -c -10 myfile — Don’t scroll. Instead, paint each screen from the top, clearing the remainder of each line as it is displayed.

$ more -s myfile — Squeeze multiple blank lines into one.

$ more +/foo myfile — The +/ option specifies a string that will be searched for before each file is displayed.

$ more +10 myfile — Start at line number 10.

Apart from this option, more will support few interactive commands also. For example

:f — Show current filename

:n — Next file

:p — Previous file

b — Move backward

f — Move forward

Space — Next page

ENTER — Next Line

Read : man more

Tech Tags: linux

ODOC: cplit

csplit – Split a file into sections determined by Context

Summary :

Output pieces of FILE separated by PATTERN(s) to files `xx01′, `xx02′,…, & output byte counts of each piece to standard output. PATTERN(s) are Line Numbers or a Regexp.

Examples :

$ csplit myfile 10 40 80 — 1st file contains 1-9 lines, 2nd 10-39 , 3rd 40-79 and 4th 80-EOF.

$ csplit myfile 10 10 80 — Zero length file will be create for the 2nd parameter..

$ csplit -z myfile 10 10 60 — Same as above. But Zero length file will NOT created

$ csplit myfile /foo/ — Copy upto, but not the matching line and remaining in 2nd file.

$ csplit myfile %foobar% — skip upto, but not the matching line

Read : man csplit

Tech Tags: linux

ODOC: split

split – Split a file into pieces.

Summary :

Split is used to split a file into equal no .of lines. The output files are created with the default Prefix as ‘x’ and suffix as 2 digit number.

Examples :

$ split -l 10 myfile — Split myfile into files of 10 lines.

$ split -b 100 myfile — Split myfile into files of 100bytes.

$ split -C 25 myfile — Put at most 25bytes of lines per file.

$ split -a 4 myfile — Use suffixe of length 4 chars.

$ split -l 10 myfile myfile — Use myfile as the prefix text.

Read : man split

Tech Tags: linux

ODOC: head

head – Output the 1st part of files.

Summary :

I should have posted this after the tail command, but forgot to do so. It does exactly the opposite by printing the first 10 lines of each FILE to stdout. With more than one FILE, precede each with a header giving the file name. With no FILE, or when FILE is -, read stdin.

Examples :

$ head — Read 10 lines from stdin & dump to stdout

$ head foo — Show 1st 10 lines of the file.

$ head f1 f2 — Show 1st 10 lines of file f1 & f2 with header.

$ head -q f1 f2 — same as above But with-out header.

$ head -n 5 myfile — Show 1st 5 lines only.

$ head -c 15 myfile — Show 1st 15Bytes only.

$ head -c 15k myfile — Show 1st 15KB only.

Read : man head

Tech Tags: linux

ODOC: shutdown

shutdown — Bring the system down (Needs Root privilege)

Summary :

shutdown brings the system down in a secure way. All logged-in users are notified that the system is going down, and login is blocked. All processes are first notified that the system is going down by the signal SIGTERM. Runlevel 0 is used to halt the system, runlevel 6 is used to reboot the system. However please take care not to use this command on production systems.

Examples :

# shutdown 12:00 — Shutdown at 12:00

# shutdown +10 — Shutdown after 10min

# shutdown now — Immediate shutdown (now == +0)

# shutdown -t 10 — Wait 10 Sec after warn the user

# shutdown -k — Don’t really shutdown; only warn

# shutdown -r -t 5 — Reboot after shutdown

# shutdown -h -t 5 — Halt after shutdown

# shutdown -f now — Skip fsck (File System Check) on reboot

# shutdown -F now — Force fsck on reboot

# shutdown -c — Cancel the already waiting shutdown process.

Read : man shutdown

There has been a great deal of flooding in Chennai, India due to the heavy rain yesterday and there was no power in the morning. I have written about the plight of people due to the floods in my personal blog.

Tech Tags: linux

ODOC: tail

tail – Output the last part of files.

Summary :

Print the last 10 lines of each FILE to stdout. With more than one FILE, precede each with a header giving the file name.

Examples :

$ tail foo.txt — Show only the last 10 Lines.

$ tail f1 f2 — Show the last 10 lines of 2 files with small header.

$ tail -vn 5 myfile — Show only last 5 Lines with header.

$ tail -c 12 myfile — Show only last 12 Bytes.

$ tail -q myfile — Don’t show headers.

$ tail –retry myfile — Keep retrying to open myfile.

$ tail -f maillog — Output appended data as the file grows. Useful to monitor logs.

$ tail -f -s 10 maillog — Once in every 10s update the output.

$ tail -f –pid=200 myfile — Terminate tail after PID (200) dies.

Read : man tail

Tech Tags: linux

Make Firefox 1.5 work with all extensions

The most common problem with Firefox1.5 is that most old extensions don’t work. There is a workaround for this though. A simple modification to the Firefox Configuration will do the trick.

  1. At the location bar type about:config. This will show a list of firefox preferences.
  2. Right click on the list and select New > String. Enter