I'm new to shell scripting. I've tried to search online, but I couldn't find what I was looking for - how do I cut a variable to get the value I'm looking for?
for example I have:
Result=`awk -F : -v "Title=" -v "Author=" 'tolower() == tolower(Title) && tolower() == tolower(Author)' BookDB.txt`
//which will return:
//Result= Black:Hat:12.30:20:30
I've tried doing this, but it won't work:
PRICE= cut -d ":" -f 3 $Result
Any help would be appreciated, thanks!
Your code is not wrong ... well, at least most of it!
Doing echo 'Result= Black:Hat:12.30:20:30' | cut -d ":" -f 3
will give the result 12.30
.
The issue is that you probably want to use it on a shell script.
To do that just try the following:
PRICE=`cut -d ":" -f 3 $Result`
What I did was basically putting `
before and after the expression that you want to store in your variable.
Reference to learn more: http://www.freeos.com/guides/lsst/ch02sec08.html
Best of luck!