![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Parse Logfile output variable | Ikon | Shell Programming and Scripting | 11 | 12-12-2008 10:37 AM |
| To parse through the file and print output using awk or sed script | cdfd123 | Shell Programming and Scripting | 4 | 03-03-2008 12:07 PM |
| How to parse through a file and based on condition form another output file | sivasu.india | UNIX for Advanced & Expert Users | 6 | 02-28-2008 04:59 AM |
| parse through one text file and output many | sophiadun | UNIX for Dummies Questions & Answers | 14 | 02-20-2008 06:08 AM |
| Parse ping output | palm101 | Shell Programming and Scripting | 3 | 11-11-2007 12:16 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
parse csv file, sha1 hash and output
I have a file, not really a csv, but containing delineated data just the same. Lets call that file "raw_data.txt". It contains data in the format of company name:fein number like this:
Code:
first company name:123456789 second company name:987654321 Code:
first company name:f7c3bc1d808e04732adf679965ccc34ca7ae3441 second company name:bfe54caa6d483cc3887dce9d1b8eb91408f1ea7a Code:
read FILE
while read line
do
awk 'BEGIN{FS=OFS=":"}{print $1, $2}'
done < $FILE
|
|
||||
|
i think the command I'm actually going for is sha1sum. When i modified the first snipit you posted to this it seemed to work
Code:
IFS=":" && \
while read name fein
do echo "$name:"$(sha1sum <<< $fein)
done < raw_data.txt > hashed_data.txt
the accurate hash of 123456789 should be f7c3bc1d808e04732adf679965ccc34ca7ae3441 Code:
echo -n 123456789 | sha1sum so need a way to trim the newline feed out of there. Code:
tr -d '\n' |
|
||||
|
Quote:
Code:
first company name:179c94cf45c6e383baf52621687305204cef16f9 -second company name:a1b42d633e975efc2f665bda21f94e419c1b6074 - |
|
||||
|
Okay take the -n out of the echo.
try this before the echo statement Code:
fein=`echo $fein | tr -d /\n/` Code:
fein=`echo -n $fein` |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| awk, awk trim, bash, csv, md5sum, sha1sum, trim, trim awk |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|