Unix Simplicity
A technology blog covering AWK and unix shell scripting.
Home
Thursday, May 15, 2008
This Michigan girl scout sold 17,328 boxes of cookies this year...
Monday, May 12, 2008
ProjectSpaces - Simple Extranet For Online Project Collaboration
I'm always attracted to new solutions that promise to be simple.
Simplicity is fun and satisfying. I think that making a process simpler is a high form of intelligence.
So, I was excited to read about ProjectSpaces, which is project collaboration software that allows the members of a company's project team to be able to work together virtually - even when they are scattered around the world.
They can securely share documents through online file sharing, coordinate tasks, maintain email lists, and schedule each other for meetings and synchronize calendars.
In short, the team can simply set up a project extranet that functions like a company intranet - without all the maintanance and overhead.
Simplicity is fun and satisfying. I think that making a process simpler is a high form of intelligence.
So, I was excited to read about ProjectSpaces, which is project collaboration software that allows the members of a company's project team to be able to work together virtually - even when they are scattered around the world.
They can securely share documents through online file sharing, coordinate tasks, maintain email lists, and schedule each other for meetings and synchronize calendars.
In short, the team can simply set up a project extranet that functions like a company intranet - without all the maintanance and overhead.
Unix Command Line For Loop
If you are working in a unix (or linux) environment, you might find the command line 'for' loop to be handy for automating different tasks.
Below are three examples of the 'for' loop. All the commands are in italics and should be entered on the command line, followed by a carriage return.
Note that, after entering the initial 'for' line, you will get the secondary unix prompt, which is usually a ">".
1. Rename all ".old" files in the current directory to ".bak":
Here, we looped thru all files with extension ".old", setting the variable "i" to be the file name we are currently looping thru. Then, between the "do" and "done", we have the body of the loop. On each pass, we echo the file name ("i") to the unix stream editor sed. Sed replaces the "old" with "bak" (so file "a.old" becomes "a.bak"), and saves the changed name to variable "j". Then, we use the unix move (mv) command to rename the original file (ex. a.old) to the new file (a.bak).
2. Change all instances of "yes" to "no" in all ".txt" files in the current directory.
Back up the original files to ".bak".
In this case, we rename each file from ".txt" to ".bak". Additionally, we use sed a second time, on the contents of the original file (now with a ".bak" extension) and save the modified text back to the original name (with ".txt").
3. Loop thru a text file containing possible file names.
If the file is readable, print the first line, otherwise print an error message:
Here, we loop thru the results of a command (in this case "cat"), rather than looping thru files in the directory. We also use an if statement with the "test" command to test for a condition (in this case, whether the file is readable).
Below are three examples of the 'for' loop. All the commands are in italics and should be entered on the command line, followed by a carriage return.
Note that, after entering the initial 'for' line, you will get the secondary unix prompt, which is usually a ">".
1. Rename all ".old" files in the current directory to ".bak":
for i in *.old
do
j=`echo $i|sed 's/old/bak/'`
mv $i $j
done
Here, we looped thru all files with extension ".old", setting the variable "i" to be the file name we are currently looping thru. Then, between the "do" and "done", we have the body of the loop. On each pass, we echo the file name ("i") to the unix stream editor sed. Sed replaces the "old" with "bak" (so file "a.old" becomes "a.bak"), and saves the changed name to variable "j". Then, we use the unix move (mv) command to rename the original file (ex. a.old) to the new file (a.bak).
2. Change all instances of "yes" to "no" in all ".txt" files in the current directory.
Back up the original files to ".bak".
for i in *.txt
do
j=`echo $i|sed 's/txt/bak/'`
mv $i $j
sed 's/yes/no/' $j > $i
done
In this case, we rename each file from ".txt" to ".bak". Additionally, we use sed a second time, on the contents of the original file (now with a ".bak" extension) and save the modified text back to the original name (with ".txt").
3. Loop thru a text file containing possible file names.
If the file is readable, print the first line, otherwise print an error message:
for i in `cat file_list.txt`
do
if test -r $i
then
echo "Here is the first line of file: $i"
sed 1q $i
else
echo "file $i cannot be open for reading."
fi
done
Here, we loop thru the results of a command (in this case "cat"), rather than looping thru files in the directory. We also use an if statement with the "test" command to test for a condition (in this case, whether the file is readable).
Wednesday, April 30, 2008
Bonus Testing Scripts
My investing book, Stock Trading Riches, includes awk and perl scripts that can be used, along with free data from BarChart.com, for testing the Stock Trading Riches formula.
The book both prints the scripts and includes links to where they can be accessed online.
As a further bonus, the Stock Trading Riches formula is also now available as a Microsoft Excel spreadsheet. This spreadsheet can be downloaded from http://www.StockTradingRiches.com/word.html - where "word" is the third word in the first paragraph on page 12 of my book.
The book both prints the scripts and includes links to where they can be accessed online.
As a further bonus, the Stock Trading Riches formula is also now available as a Microsoft Excel spreadsheet. This spreadsheet can be downloaded from http://www.StockTradingRiches.com/word.html - where "word" is the third word in the first paragraph on page 12 of my book.
Thursday, April 24, 2008
Secret to A Fast, Stable Computer Environment
I heard this sage advice years ago: "Always try to use the most recent hardware, but the oldest version of software you can get away withÂ…"
Tuesday, April 22, 2008
Sony Sells First OLED TV
It's thinner and sharper than both LCD and plasma, but expensive right now.
Monday, April 21, 2008
Selling Extra Copy of James Brausch's How to Create A DVD Product
As I mentioned in a previous post about selling Stock Trading Riches as a book and eBook, selling physical products online has a higher conversion rate, because people know that you are more serious.
If you want to start selling physical products, you may want to get a copy of James Brausch's Earn an Income By Creating Your Own DVD.
He sells this DVD for $100 (plus $5 shipping and handling) through Kunaki, but I have an extra copy I'm selling on Ebay. It is brand-new, unopened, and still shrink-wrapped.
If you want to start selling physical products, you may want to get a copy of James Brausch's Earn an Income By Creating Your Own DVD.
He sells this DVD for $100 (plus $5 shipping and handling) through Kunaki, but I have an extra copy I'm selling on Ebay. It is brand-new, unopened, and still shrink-wrapped.
Earn An Income By Creating Your Own DVD
Tuesday, April 08, 2008
Refreshing, User-friendly Captchas
I'm tired of seeing most captchas - they make you strain to decipher numbers and letters that have been turned and twisted in ungodly ways ;-)
But, I have seen some captchas that are clever - they foil automation, but they are user-friendly.
These captchas ask questions like "How many months are in September?", "What day comes before Wednesday?" or "What is the opposite of North?"
These are most refreshing!
But, I have seen some captchas that are clever - they foil automation, but they are user-friendly.
These captchas ask questions like "How many months are in September?", "What day comes before Wednesday?" or "What is the opposite of North?"
These are most refreshing!
Automatic Forwarding With JavaScript
Here is a simple javascript that will randomly forward you to either yahoo (50% of time) or google (50%). This could be used for split testing websites.
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
//-->
var i = Math.round(100*Math.random());
if (i<=50)
{
window.location="http://www.yahoo.com";
}
if (i>50)
{
window.location="http://www.google.com";
}
</script>
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
<!--
//-->
var i = Math.round(100*Math.random());
if (i<=50)
{
window.location="http://www.yahoo.com";
}
if (i>50)
{
window.location="http://www.google.com";
}
</script>
Labels: OtherLangs

