ksh :: want to cut the strings

I have contents like

423562143124/53125351276
sdgas/347236
sjhdk;ls'ald/y62783612763

I need a command that would make the string before / and after / as separate output as (A should contain 423562143124 )and B should
contain 53125351276).

I tried but in vain.

Please help.

awk 'BEGIN {FS="/"} {print $1 "," $2}' file

but the output
423562143124/53125351276 is already stored in a variable '$tea'

Is it possible to use the awk command on $tea.

May i know that please.

echo $tea | awk 'BEGIN {FS="/"} {print $1 "," $2}'

I am not getting the values in $1 and $2.

Is there any other way to follow this?

What do you get instead?

I dont get any values for those $1 and $2

So, try this:

awk -F/ '{ print $1 "," $2 }' inputfile.txt

no values are there. its just blank

Okay, just for kicks, do:

head -4 inputfile.txt

i substituted the value for tea.

how to give the command with $tea?

i gave the command in my script as

echo $fol | awk -F/ '{ print $1 "," $2 }'

will this succeed?
I just et the output as

valueof$1,valueof$2

This is not getting substitute in the place of $1 or @2 individually.

I am having difficulty understanding your English. Please give exact contents of the file (using "head") and an accurate log of output.

> tea="423562143124/53125351276"
> echo $tea|tr -s "/" " "|awk '{print $1,$2}'
423562143124 53125351276

This could put you in the right direction:

#!/bin/ksh

var=`echo '423562143124/53125351276'| tr '/' ' '`

set $var

echo "$1"
echo "$2"

Regards

while read LINE
do
A=`echo $LINE|tr '/' ' '|awk '{print $1}'`
B=`echo $LINE|tr '/' ' '|awk '{print $2}'`
echo "$A : $B"
done < input_file_name

the data to be put in LINE is like
10dfs 20-gy 30=tyop/40tup 50poi 60-ghu

when i gave this data in
A=`echo $LINE|tr '/' ' '|awk '{print $1}'`
B=`echo $LINE|tr '/' ' '|awk '{print $2}'`
echo "$A"
echo "$B"

output is like
A = 10dfs
B = 20-gy

But i want the output like this
A = 10dfs 20-gy 30=tyop
B = 40tup 50poi 60-ghu

Nevermind "tr". That was a false direction.

A=`echo $LINE|awk -F/ '{print $1}'`
B=`echo $LINE|awk -F/ '{print $2}'`
echo A=$A
echo B=$B

You can use parameter expansion:

LINE="10dfs 20-gy 30=tyop/40tup 50poi 60-ghu"
echo "A = ${LINE%%/*}"
echo "B = ${LINE##*/}"

while read LINE
do
A=`echo $LINE|cut -d"/" -f1`
B=`echo $LINE|cut -d"/" -f2`
echo "$A : $B"
done < input_file_name