4234234 US phone
3244234 US cup
2342342 CA phone
8947234 US phone
2389472 CA cup
2348972 US maps
3894234 CA phone
I want the records with (US,phone) as record to be in one file, (Us, cup) in another file and (CA,cup) to be in another
I mean all records with the last two records forming unique pair in the one file itself
Is it possible in awk?
Thanks vino, it worked
I have one more question
If the file is like this
WSRTK10000000000000067839904809787489959595924667889USMNC
WSRTK10000893479900006783990480978748995959592466673CNATT
WSRTK10000893472387462342349899000067839904809787455USAPT
I know that the last 5 characters in each line is my search pattern and my problem remains the same
I want lines containing patterns like USMNC to go to US_MNC etc
Can I extract last few characters of each line in awk?
In this case, your output file will contain each line delimited by spaces between the first long stretch of characters then US and then the last 3 characters.
Not 100% right, but close. Have to figure out why..
#! /bin/sh
while read line
do
name=`echo $line | sed -n -e 's/\(.*\)\([A-Z][A-Z]\)\([A-Z][A-Z][A-Z]\)/\2_\3/p'`
echo "$line" >> $name.txt
done < list.txt
Where $name will have the value like US_APT et al.. and list.txt is your input file.