![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell script for text extraction from a file | vignesh53 | Shell Programming and Scripting | 3 | 02-05-2008 05:16 AM |
| AWK extraction | harris2107 | Shell Programming and Scripting | 2 | 01-15-2008 08:44 AM |
| AWK extraction | harris2107 | Shell Programming and Scripting | 3 | 08-17-2007 02:02 AM |
| Data Extraction issue. | irehman | Shell Programming and Scripting | 5 | 04-06-2006 05:28 AM |
| Help with tar extraction! | manthasirisha | Shell Programming and Scripting | 4 | 03-17-2006 04:17 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
help with data extraction script
Hello all,
Iam newbie here and to unix programming. I have the following text file. Code:
A:Woshington,B:London,C:Paris,D:Manchester,C:Lisbon,E:Cape town. Code:
CITY1:`echo "$text" | grep "A:" |awk '{print $0 }'`
CITY2 :`echo "$text" | grep "B:" |awk '{print $0 }'`
CITY3:`echo "$text" | grep "C:" |awk '{print $0 }'`
CITY4:`echo "$text" | grep "D:" |awk '{print $0 }'`
CITY5:`echo "$text" | grep "E:" |awk '{print $0 }'`
CITY6:`echo "$text" | grep "F:" |awk '{print $0 }'`
mam |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
How you need the output?Are you looking for the entire block seperated with colon or just the City name ?
|
|
#3
|
|||
|
|||
|
DILEEP410,
Thanks for your reply, For the output, I need only city names and then I will use them to store in database. like CITY1=Washington,CITY2= ..., Thank you again for your help mam |
|
#4
|
|||
|
|||
|
Sorry I think the code should read like this
Code:
CITY1=`echo "$text" | grep "A:" |awk '{print $0 }'`
CITY2 =`echo "$text" | grep "B:" |awk '{print $0 }'`
CITY3=`echo "$text" | grep "C:" |awk '{print $0 }'`
CITY4=`echo "$text" | grep "D:" |awk '{print $0 }'`
CITY5=`echo "$text" | grep "E:" |awk '{print $0 }'`
CITY6=`echo "$text" | grep "F:" |awk '{print $0 }'`
|
|
#5
|
|||
|
|||
|
Please, anyone with idea?.
I really need your support expert! Thank you again |
|
#6
|
|||
|
|||
|
passing paramaters to a shell variable
could some one tell me, how could i pass the wilcard notation given as input to variable $1 which acts as variable that matches files in the directory and the delete them.
|
|
#7
|
|||
|
|||
|
GNU awk
Code:
awk 'BEGIN{FS=",*[a-zA-Z]:"}
{
for ( i=2 ; i<=NF ; i++ ) {
print "insert table values (\047" $i "\047)"
}
}
' "file"
Code:
# ./testnew.sh
insert table values ('Woshington')
insert table values ('London')
insert table values ('Paris')
insert table values ('Manchester')
insert table values ('Lisbon')
insert table values ('Cape town.')
|
|||
| Google The UNIX and Linux Forums |