[NTLUG:Discuss] YAS Yet Another Script
Paul Ingendorf
pauldy at wantek.net
Fri Oct 12 19:12:59 CDT 2001
Yea that is a typo you can change the for lop to read
for line in `cat "$file" | sed -e "s/ /__/g"`
or you could change the echo to read
echo "$basefile,$lines" | sed -e "s/__/ /g" >> "$basefile.asc"
either way will give you the result you want I should have read closer before sending.
--
-->> mailto:pauldy at wantek.net
-->> http://www.wantek.net/
Running ....... Cos anything else would be a waste...
`:::' ....... ......
::: * `::. ::'
::: .:: .:.::. .:: .:: `::. :'
::: :: :: :: :: :: :::.
::: .::. .:: ::. `::::. .:' ::.
.:::.....................::' .::::..
-----Original Message-----
From: discuss-admin at ntlug.org [mailto:discuss-admin at ntlug.org]On Behalf
Of Wrenn, Bobby J.
Sent: Friday, October 12, 2001 9:02 AM
To: 'discuss at ntlug.org'
Subject: RE: [NTLUG:Discuss] YAS Yet Another Script
Well, that mostly worked. The input ".csv" file has several lines which look
like this:
A3189A,1,HP 9000 K460 Upgrade
The output file looks like this:
CPSUB BTEC AMER K420,
for as many lines as are in the input file.
What I need is lines like this:
CPSUB BTEC AMER K420,A3189A,1,HP 9000 K460 Upgrade
for each line in the input file.
Here is the original script:
#!/bin/bash
for file in *.csv
do
basefile=`basename "$file" .csv`
for lines in `cat "$file" | sed -e "s/ /__/g"`
do
echo "$basefile,$line" | sed -e "s/__/ /g"
>> "$basefile.asc"
done
done
I think I see the problem. Which means I may be actually learning something.
The echo line calls the variable $line. But I don't see it either defined or
read.
Here is a suggestion for a presentation "Regular Expressions" and "Shell
Scripting".
Thanks again,
Bobby
_______________________________________________
http://www.ntlug.org/mailman/listinfo/discuss
More information about the Discuss
mailing list