More Fun bits of Bash / Sed and Awk Shell Fun
So you want to split a file in two (even or uneven).
The command `split` will do this for you.
Should you wish to use it, it defaults to 1000 lines for large files as the point to split a file.
However, if you want to split a file which has 701 lines and you want to split it at the 502 line, then you would simply do this:
split -l502 SplitMeFileName
and the file would be split in two pieces.
They would be called xaa and xab unless you state what the file should be called.
Nine Digits turned into something with two decimal places, and with commas for thousands.
sed ‘s/./\.&/8′ FileWithNumbersToBeParsed | sed ‘s/./\,&/5′ | sed ‘s/./\,&/2′ >foo
or how to turn
123456789
into
1,234,567.89
The .& or ,& puts the comma or decimal point in the correct location, start on the right hand side or you will have more fun than you need.
(try it to find out )
This is how you insert a character into a string.
You want to put a leading space into every line in a file?
sed ‘s/./\ &/’ FileName
What might not be obvious from this line is the space before the &.
And some Awkdate | awk '{print $2 " " $6}' how to print specific strings from some random input. date Wed Apr 6 23:15:10 IST 2011 we get the output Apr 2011 That's all folks.