in summary.. SEE Below
In file1, line 1 (<html>...unique identifier23432..</html>) needs to be > to the identifier in line 1 in file2 (creating a NEW file name for each record)(23432).html (creating new file based on unique identifier)
---------- Post updated at 08:51 AM ---------- Previous update was at 08:36 AM ----------
#!/bin/ksh
#create counter
cnt=0
# read lines from stdin
while read line
do
# remove begin of line including <html>
a1=${line#*<html>}
# remove end of line including </html>
a2=${a1%</html>*}
# remove all char except numbers (replace not numbers with nothing)
a3=${a2//[^0-9]/}
print $a3
#increment cnt for testing creation of new unique identifier
cnt=$(($cnt+1))
done > $cnt.html
$ksh test3.ksh
test3.ksh[17]: : bad substitution
$
This 1 file is created:
0 Jun 28 08:41 0.html
blank and no 1,2, 3 and so forth..
Any other ideas?
Quote:
Originally Posted by kshji
You can do this many way, but here is one example how to use parameter expansion.
Code:
#!/bin/ksh
# read lines from stdin
while read line
do
# remove begin of line including <html>
a1=${line#*<html>}
# remove end of line including </html>
a2=${a1%</html>*}
# remove all char except numbers (replace not numbers with nothing)
a3=${a2//[^0-9]/}
print $a3
done
And then run it
Code:
chmod a+x thisfile
cat file1 | ./thisfile > file2
|
Thank you but unfortunately, this will not create what I need..
in summary.. SEE Below
In file1, line 1 (<html>...unique identifier23432..</html>) needs to be > to the identifier in line 1 in file2 (creating a NEW file name for each record)(23432).html (creating new file based on unique identifier)
---------- Post updated at 08:51 AM ---------- Previous update was at 08:36 AM ----------
#!/bin/ksh
#create counter
cnt=0
# read lines from stdin
while read line
do
# remove begin of line including <html>
a1=${line#*<html>}
# remove end of line including </html>
a2=${a1%</html>*}
# remove all char except numbers (replace not numbers with nothing)
a3=${a2//[^0-9]/}
print $a3
#increment cnt for testing creation of new unique identifier
cnt=$(($cnt+1))
done > $cnt.html
$ksh test3.ksh
test3.ksh[17]: : bad substitution
$
This 1 file is created:
0 Jun 28 08:41 0.html
blank and no 1,2, 3 and so forth..
Any other ideas?
Quote:
Originally Posted by kshji
You can do this many way, but here is one example how to use parameter expansion.
Code:
#!/bin/ksh
# read lines from stdin
while read line
do
# remove begin of line including <html>
a1=${line#*<html>}
# remove end of line including </html>
a2=${a1%</html>*}
# remove all char except numbers (replace not numbers with nothing)
a3=${a2//[^0-9]/}
print $a3
done
And then run it
Code:
chmod a+x thisfile
cat file1 | ./thisfile > file2
|
---------- Post updated at 11:40 AM ---------- Previous update was at 08:51 AM ----------
Thank you but unfortunately, this will not create what I need..