I have a file which contains lines looks like this:
ISC Egypt-Alex2 126 104541338 218926893238 f 1B
ISC BT-Colindale 26 249126190534 218913486850 b 29
ISC Egypt-Cairo2 199 129026052 218927661509 b 26
As you see in each line $4 and $5 are phone numbers , i want a script which process this file and its output should be like this :
ISC Egypt-Alex2 126 104541338 218926893238 f 1B Egypt-Vodafone Libya-Libyana
ISC BT-Colindale 26 249126190534 218913486850 b 29 ZAIN Sudan Libya-Madar
ISC Egypt-Cairo2 199 129026052 218927661509 b 26 Mobinil-Egypt Libya-Libyana
As you see there i need two fields to be added according the country code of the phone numbers
For sure there are another country codes so please can any one advise how could it be done on some country codes as example and i will add the others by analogy
Not going to happen until you tell us where we can obtain the information that you want to be added to each line.
If you need it to be fast, it sounds like you might want to port all of this to an SQL database, depending somewhat on how often you will need to do this processing.
So the script should add the two new fields with the names of countries according to code of $4 and $5
i can prepare to you a file and send it to you if this is the information you need , if else please update me
Regarding the speed i wont prefer to load the data to my SQL because it will waste time for me so please can you have subsitute solution after sending you the required file you need.
You want speed, but loading it up into a faster engine is a waste of your time? Well, your call.
Load the prefix code to operator mapping into a hash and the rest will be trivial. Prepare to learn some Perl if you don't know it already.
This is only very briefly tested, proof of concept code. The output is not what you want, but I trust you can glue things together (by trial and error, if not otherwise). Google for a quick Perl intro if you are not familiar with the language, there are tons of those.
In case it's not painfully obvious, it expects the operator to mapping table in a text file called mappings.txt in the current directory, and reads standard input. Here is a demo run.
Thanks for your reply; just i want to check on a certain issue:
Regarding mapping.txt files it will contain large number of country codes ; so will this affect or it is ok?
Regarding your code what i understand that the first block is loading the mapping.txt into hash then the second block is reading my lines and matching it with the hash contents
If you please tell me the meaning of each line just to understand if this will disturb you so no problem.
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)
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)
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)
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)
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)
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)