.
Computing / bash Scripting

Computing | Cygwin >
U N D E R   C O N S T R U C T I O N

bash Scripting Tips and Tricks

Quick Tips

  1. To convert lower case (on stdin) to upper (on stdout): tr a-z A-Z

Extended Tips

Read a file (or command output) into a array, with each line as a single array element

The following reads the contents of MAKE_KML.TMP into a new array RAWDATA, one line per array element, and then reads the output of the grep command (sorted and then throwing out redundant lines) into RAWDATA2, one line of output per array element:

#!/bin/bash
IFS='
'
RAWDATA=( $(< MAKE_KML.TMP) )
RAWDATA2=( $(grep SLAT *.buf | sort | uniq) )

The first two lines set newline as the field separator. You may want to set it back to space after reading the file into the array.

IFS=' '


Any coward can fight a battle when he’s sure of winning.

George Eliot

A2 Web Hosting
Creative Commons License
Get your Domain at GoDaddy.com
Look for:

loaded 2012-02-06 01:48:03 • last modified 2010-04-05 10:43:37
Privacy PolicyDisclaimer
• awcolley.com is powered by PmWiki v.2002016 •
• all content (unless otherwise noted) © 2012 A W Colley