Script for Country Codes


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Script for Country Codes
# 15  
Old 04-03-2008
This is very strange!! your command is exactly as it should be!!

Try the following and let me have the result:

Code:
uname -a
echo "{$(sed 's=\(.*\) \(.*\)=if($4~/^\2/)print $0\" \1\"=' country-codes.txt)}" >awk_4
head awk_4
tail awk_4
awk -f awk_4 phonelines.txt >first_added
head first_added
tail first_added
echo "{$(sed 's=\(.*\) \(.*\)=if($5~/^\2/)print $0\" \1\"=' country-codes.txt)}" >awk_5
head awk_5
tail awk_5
awk -f awk_5 first_added

# 16  
Old 04-03-2008
Reply

Dear Unilover

I typed the commands you told me the result is :
geo@spiserver /home/geo/cdr/ItalyRel 5 > uname -a
echo "{$(sed 's=\(.*\) \(.*\)=if($4~/^\2/)print $0\" \1\"=' country-codes.txt)}" >awk_4
head awk_4
tail awk_4
awk -f awk_4 phonelines.txt >first_added
head first_added
tail first_added
echo "{$(sed 's=\(.*\) \(.*\)=if($5~/^\2/)print $0\" \1\"=' country-codes.txt)}" >awk_5
head awk_5
tail awk_5
awk -f awk_5 first_added
SunOS spiserver 5.8 Generic_108528-23 sun4u sparc SUNW,Sun-Fire-280R
Variable syntax


Same one variable Syntax ; Note that i am using Solaris 8 may be this cause problems!! but i don't think so

Anyway the first code you gave me before the faster code is working but i want to pipe the final result in a single which i can't do moreover the code is very slow

The most important that when i type the first command:
sed 's=\(.*\) \(.*\)=if($4~/^\2/)print $0\" \1\"=' country-codes.txt

it generates the if loops as you said but when i type this code alone:
awk "{$(sed 's=\(.*\) \(.*\)=if($4~/^\2/)print $0\" \1\"=' country-codes.txt)}" phonelines.txt

The result is variable sysntax

Please advise
# 17  
Old 04-04-2008
If it's a really old shell it might not understand $(...)

zanetti: Does $(echo echo moo) print "moo" for you?

Does echo "{moo}" print "{moo}" for you?

Does echo "{$(echo moo)}" print "{moo}" for you?

Code:
vnix$ $(echo echo moo)
moo
vnix$ echo "{moo}"
{moo}
vnix$ echo "{$(echo moo)}"
{moo}

# 18  
Old 04-04-2008
OK, looks like era is righ. Please try this:
Code:
echo "{`sed 's=\(.*\) \(.*\)=if($4~/^\2/)print $0\" \1\"=' country-codes.txt`}" >awk_4
head awk_4
tail awk_4
awk -f awk_4 phonelines.txt >first_added
head first_added
tail first_added
echo "{`sed 's=\(.*\) \(.*\)=if($5~/^\2/)print $0\" \1\"=' country-codes.txt`}" >awk_5
head awk_5
tail awk_5
awk -f awk_5 first_added

and then copy and paste whatever is displayed.
# 19  
Old 04-04-2008
It works very well

It works very well
# 20  
Old 04-04-2008
Reply

I am not right now in location where i can execute but i wanna ask question:

Last Reply mentioned by Unilover i want the final out put to be directed in one file so will this script make this ?

Regarding speed ? does it seems good ?

Thanks alot
zanetti
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Forum Support Area for Unregistered Users & Account Problems

Registering from blocked country

Hi, I'm come from Vietnam and want to join to Unix forum just because I like Unix programming and want to learning more. My IP is allocate by DHCP server so it is dynamic. Here is my desired username and my email: Username: lucasdo Email: rennersstar@gmail.com Thank you very much for... (0 Replies)
Discussion started by: lucasdo
0 Replies

2. Shell Programming and Scripting

ip 2 country sorting[solved]

Dear folks. I have list of ip address from different country, i would like check from script this ip address belong to which country, please suggest any command, i have more than 200 ip address so i need to do it via script. Script will show me country code and its City if possible? ... (0 Replies)
Discussion started by: learnbash
0 Replies

3. Shell Programming and Scripting

Bash Shell Script Exit Codes

Here is my daily stupid question: How can I tell a script to only execute if the other scripts exits successfully? So "script A" executes and it executes successfully (0),then "script B" will run or else "script A "executes and it exits unsucessfully (1) then "script B" will read return... (6 Replies)
Discussion started by: metallica1973
6 Replies

4. Shell Programming and Scripting

'watch' not interpreting escape codes in bash script

Hi there, I'm fairly new to bash scripting and already having some troubles. I'm making a script that can print some series of strings in colors based in the information of a file, for simplicity let's say it only does: #!/bin/bash printf "\eWhen you execute this in the command line it... (1 Reply)
Discussion started by: Arashi
1 Replies

5. Shell Programming and Scripting

whois country help

Hello folks, I have list of ips like 1.1.1.1 2.2.2.2 3.3.3.3 4.4.4.4 whois 1.1.1.1 |grep -E 'country|Country' it show country=US or whatever. so i have number of ips in text file, how i can use above script to automate output like 1.1.1.1 US 2.2.2.2 CA 3.3.3.3 FR (3 Replies)
Discussion started by: learnbash
3 Replies

6. UNIX for Advanced & Expert Users

Country Codes script faster response ;please help

Dear all I have group of input lines which look like this These input lines is placed in a file named phonelines.txt and there is a script which match $4 and $5 with country codes placed in another file named country-codes.txt and its contents is : Italy 39 Libyana 21892 Thuraya... (12 Replies)
Discussion started by: zanetti321
12 Replies
Login or Register to Ask a Question