Hi people,
I've encountered a problem. I have a data file like:
asd:$123:2
zxc:$456:4
But when I want to extract "$123" and get the number with this command:
echo $123 | cut -c 1-10
Im returned with 23 instead of 123.
Please help me out, thanks.
Hi people,
I've encountered a problem. I have a data file like:
asd:$123:2
zxc:$456:4
But when I want to extract "$123" and get the number with this command:
echo $123 | cut -c 1-10
Im returned with 23 instead of 123.
Please help me out, thanks.
not sure what you are doing!!
echo $123 | cut -c 1-10
the above will give ouput you the characters from 1 to 10 from the data stored in the variable.
is that what you are trying?
-ilan
][, [[]] ][,
$1 = first parameter from the command line
echo $123
is equal to
echo -n "$1"
echo -n "23"
and if the parameter $1 is empty then it is equal to
echo "23"
In other words you are EXECUTING the string.
Hints how to solve this problem:
sed -e 's/\(^.*:\$\)\(.*\)\(:.*$\)/\2/g' datafile
This suffice:
sed 's/.*\$\(.*\):.*/\1/' file
Regards