Wednesday, November 30, 2011
Monday, November 28, 2011
Shell Code to Recursively search a directory for files and process them one by one
#!/bin/sh
$FILENAME="RECORDS"
for FILE in `find . -name $FILENAME`
do
## Process $FILE
echo "FILE: $FILE"
cat "$FILE" |
(
# Read Header but don't process it
read line
# Read records
while read line
do
echo $line
done
)
done
The above shell script code searches through current directory (and subdirectories) for all files with name RECORDS. It then reads the files one by one and processes them line by line.
Eg. If your record file is like follows
"Name","TelNo"
"A","1"
"B","2"
...
Then you could put following code to read off all names in while loop.
$NAME=`echo $line| cut -d"," -f1`
echo $NAME
$FILENAME="RECORDS"
for FILE in `find . -name $FILENAME`
do
## Process $FILE
echo "FILE: $FILE"
cat "$FILE" |
(
# Read Header but don't process it
read line
# Read records
while read line
do
echo $line
done
)
done
The above shell script code searches through current directory (and subdirectories) for all files with name RECORDS. It then reads the files one by one and processes them line by line.
Eg. If your record file is like follows
"Name","TelNo"
"A","1"
"B","2"
...
Then you could put following code to read off all names in while loop.
$NAME=`echo $line| cut -d"," -f1`
echo $NAME
Friday, November 25, 2011
Getting up and facing the Sun
About four months ago, I pulled down the Shutter! On blogging, on most of new things I was involved in, and I killed a few old processes too. There wasn't much happening around for me. The world meanwhile has moved ahead. Unity has seen some noticeable improvements, gnome 3 is also getting better, both of them picking good ideas from each other, Ubuntu is trying to break into tablet space, Linux Mint not wanting to disappoint many fans of classic desktop has chosen MGSE (Mint Gnome Shell Extensions ) to lead the way for them and they are also working on Mate - A fork of Classic Gnome (gnome 2.32). Meanwhile there are other people who have switched to XFCE/ LXDE etc.
Lots and lots happening around with Fedora and OpenSUSE both releasing major versions that look and feel promising. I have downloaded Fedora 16 but I'm yet waiting to get a spare USB to put it on my Laptop. The Live Desktop does look promising but in the end it's the things that are after an install that matter. Follows my current state of affairs!
Subscribe to:
Posts (Atom)