Hello,
This one has me stumped, although I suspect it might be easy. I have a file and need to split the entries into two varaibles. The format for a positive is 'AANNNN' where A is alpha and N is numeric.
Thanks in advance
Hello,
This one has me stumped, although I suspect it might be easy. I have a file and need to split the entries into two varaibles. The format for a positive is 'AANNNN' where A is alpha and N is numeric.
Thanks in advance
Since you are saying this one has you stumped .. I am assuming that you cant use cut and have looked at sed as follows.
sed -e 's/[a-z]//;s///g' filename> NumericFile
sed -e 's/[0-9]//;s///g filename> AlphaFile
sorry too early in the morning and too long staring at the screen
replace sed as follows
sed -e 's/[a-z]//g' and sed -e 's/[0-9]//g' you dont need all the extras.
I am sorry I did not make this clear. I need to split the date into those lines that match NNAAAA, and those that do not. For example:
Sample data:
aa1234
bb9876
root
nobody
Would produce one file or variable containing root and nobody, and another containing aa1234 and bb9876
if [[ $something == [a-zA-Z][a-zA-Z][0-9][0-9][0-9][0-9] ]]; then
echo one file
else
echo the other file
fi
Try...
var1=$(grep '[a-zA-Z][a-zA-Z][0-9][0-9][0-9][0-9]' file1)
var2=$(grep -v '[a-zA-Z][a-zA-Z][0-9][0-9][0-9][0-9]' file1)