Quantcast
Channel: Unix Simplicity
Browsing all 26 articles
Browse latest View live

Creating csv Files From Unix When the Data Has Commas

Here is a problem that has occurred a few times for me:I run a query on a unix database using sqlplus from a shell script. I then save the results in an csv (comma separated value) file and load it...

View Article



Using Awk to Filter A Long Directory Listing, and Strip Out The File Name

Today, a guy at work used ls -ltr to list the files in a directory, and then saved the list to a file.He then used grep 'Jan 17' file to get the files from today.He got a listing like:-rw-r--r--   1...

View Article

Multiple - Word Command Arguments in Unix

Did you know that unix command line arguments can be more than one word? You can group text separated by spaces into a single argument by surrounding the text with quotes.For example, what are the...

View Article

Handy Settings For Your Korn Shell .kshrc File

My co-worker had modified his .kshrc by adding the following four entries (highlighted in bold):alias -x ll='ls -l'umask 002stty erase "^H" kill "^U" intr "^C" eof "^D" quit "^\\" susp "^Z"PS1="\\\$PWD...

View Article

Part 1 - Creating An SQL Report Using Both Sqlplus and Unix Shell Scripts

Yesterday, I had to run a query in an Oracle database to find templates that are in more than one template group.The data is stored in a table called "TransactionTemplateGroups" and the three fields...

View Article


Part 2 - Creating An SQL Report Using Only Sqlplus

In part 1, I outlined the need to extract siteid / templatename combinations from an Oracle database table, and then group identical records and print the count.I offered the solution where I pulled...

View Article

Happy Halloween!

I publish this link on my blogs every year at Halloween time, it's pretty...

View Article

More Halloween Fun

Ben and Jerry's Halloween interactive website:http://www.benjerry.com/halloween/

View Article


Forwarding Webpages 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"...

View Article


Awk Script For Trading Stocks

Besides unix/awk scripting, I also enjoy trading stocks. Here is an awk program that takes a file of stock prices and applies the constant value investing algorithm to them.This script is also included...

View Article

3 Awk Scripts For Calculating Compound Interest

Last year, I posted 2 Awk Scripts for calculating compound interest.The "compound" script simply adds compound interest to an initial starting principle.The second script, "compound_add", uses the...

View Article

"Stock Trading Riches" is now available in Kindle format on Amazon.com

My book "Stock Trading Riches" is now available in Kindle format on Amazon.com.Since this is a new format, it's priced for now at $2.99.They did a good job in the conversion - I saw that the stock...

View Article

Using Awk to Estimate Internal Rate of Return

On my math and logic blog, I have a post explaining a quick and dirty method of calculating the approximate rate of return for a investment where additional funds were added during the year.In this...

View Article


Removing Carriage Return Line Feeds (CRLF's) From Text Files in Unix

In unix, each line in a text file ends with a line feed. Windows text files, however, end each line with a carriage return and a line feed.Normally, when you ftp a text file between Windows and unix,...

View Article

Using Read-Only Constants in Unix Shell Scripts

You can use typeset -r to make variables in a ksh script be read-only. This effectively makes them constants, which can no longer be modified.For example:[550]-> pi=3.14159[551]-> echo...

View Article


A Random Coupon Generator Written in Awk

Here is an awk script I use to generate 100 random 8-character coupon codes.Each character has 62 possibilities (a-z, A-Z, and 0-9). This means there are 8^62 possible coupon codes.BEGIN...

View Article

Temperature Conversion Through Awk

Here is an awk program to convert between celcius and Fahrenheit temperatures.   Unlike most of my programs, this program is interactive.  Once started, it interacts with the user at the command line,...

View Article


The Unix Change Directory Command

In unix, the cd command is used to change directories. For example, cd /tmp will put you in the /tmp directory.Here are some tips/tricks for cd:cd by itself or cd ~ will always put you in your home...

View Article

Programming Quotes

There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious...

View Article

Splitting a Unix File into Smaller Files

Let's say that we have a large unix file. For example, a text file called my_list with 100,000 lines.We need the data contained in smaller files with no more than 1000 lines each.We can use the unix...

View Article
Browsing all 26 articles
Browse latest View live




Latest Images