Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Maybe the AIX version of grep or ksh doesn't like the quotes around the variable?
Code:
grep "${PROP_KEY}"
What happens at command line if you do:
PROP_KEY=test
echo $PROP_KEY
echo ${PROP_KEY}
echo "${PROP_KEY}"
Typically I only use double quotes with egrep (a/k/a grep -E). Maybe the AIX version doesn't expect the quotes for standard grep. If so maybe use egrep (or grep -E) with the quotes works?
using
echo $PROP_KEY
echo ${PROP_KEY}
echo "${PROP_KEY}"
its giving the same output... correct prop_key name
AIX isn't typically a 'normal' version of Unix. Read the man page on the AIX grep utility (and the cut/tr commands too), and you'll probably spot differences. There are a few ways to address it:
Write your script to check the platform, and use a different grep/cut/tr command(s) if you're on AIX
Write a script especially for AIX
Install the GNU versions of those utilities on AIX, and use them.
I tried with above changes also.but result remains same. Still i'm not able to get RowCount_from_prop. any other alternate that can replace grep. coz i guess grep is the only one creating problem here. BUT I have same logic in some other script, WHERE its WORKING pretty fine without any issue. I'm posting a bit code here of other script.
Code:
#!/usr/bin/ksh
run_count=1
catalog_name=rrc
PROPERTY_FILE_NAME="/Dataload_Scripts/Properties/"$catalog_name"_Mandatory_Field.prop"
cd /Dataload_Scripts/Files/$catalog_name
pwd
for file in $run_count"_"*.csv; do
echo "file name "$file
PROP_KEY=""
PROP_KEY=`echo $file | cut -c3-`
echo "PROP_KEY= "$PROP_KEY
Property_Value=""
Property_Value=$(cat ${PROPERTY_FILE_NAME} | grep "${PROP_KEY}" | cut -d'=' -f2)
echo "Property_Value = "$Property_Value
Above code is working perfectly in same system same OS i.e., AIX.
Now whats the problem it has with same grep command in other script.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.