I'm just writing this out off the top of my head, so it may not be correct, but try something like this:
I *think* this should handle a similar job, although, once again, it hasn't been tested.
You'll notice a wierd line:
db_name=${db_tmp##*:}
That should drop anything before the colon... good ol' ksh...
You could save yourself a few processes by simply grabbing those lines that I used:
db_name=$(db2 "get instance")
cd /top/${db_name##*:}/apps/log
cat *${slog}*
Faster, more concise, and no "if" statements, nor a disk write and a grep. If you're going to use the Korn shell, why not use some of the builtin features to make your life easier, right?
yes, your code is better, but my system didn't like the substitution in the path, cd /top/${db_name##*:}/apps/log. The system is AIX, and I am forced to use the Korn shell, that's the only one that will work, I'd like to take more advantage of it's built in features.
case $db_name in
db2q) cd /top/db2q/apps/log/ ;;
db2u) cd /top/db2u/apps/log/ ;;
*) echo "Eek." ;;
esac
I'm not saying that you're doing it wrong - I guess I just feel uneasy with grepping a string out of a file... I usually try to touch the disk as little as possible in a small script.
Hmm, what do you think about this:
db2 "get instance" | grep "db2q" >/dev/null 2>&1
case $? in
0) cd /top/db2q/apps/log ;;
1) cd /top/db2u/apps/log ;;
*) echo "This should never happen." ;;
esac
That way is very similar to how your are doing it now, and I find case statements a little cleaner than if statements, but that's just my opinion.
Well, I hope this is helping at least a little...
It just goes to show how many ways there are to accomplish a task in Unix!
Hi all,
I am trying to find a way to change first letter in a word from lower case to upper case. It should be done for each first word in text or in paragraph, and also for each word after punctuation like
. ; : ! ?I found the following command
sed -i 's/\s*./\U&\E/g' $@ filenamebut... (7 Replies)
Hello Unix Gurus :
It would be really appreciative if can find a solution for this .
I have records in a file .
I need to Capitalize the records based on condition .
For Example i tried the following Command
COMMAND -->
fgrep "2000YUYU" /export/home/oracle/TST/data.dat | tr '' ''... (12 Replies)
Is there a command that can switch a character variable from UPPER case to lower case?
like
foreach AC ( ABC BCD PLL QIO)
set ac `COMMAND($AC)`
...
end
Thanks a lot! (3 Replies)
Hi
I want to make string substitution ignoring case for search but respecting case for subtitute. Ex changing all occurences of "original" in a file to "substitute":
original becomes substitute
Origninal becomes Substitute
ORIGINAL becomes SUBSTITUTE
I know this a little special but it's not... (1 Reply)
Hi all,
i have a data array as followes.
ARRAY=DFSG345GGG
ARRAY=234FDFG090
ARRAY=VDFVGBGHH
so on..........
i need all english letters to be change to lower case. So i am expecting to see
ARRAY=dfsg345ggg
ARRAY=234fdfg090
ARRAY=vdfvgbghh
so on........
If i have to copy this data in... (8 Replies)
Hi All
I have a script which extracts values from a Database (A persons name) and puts it into a variable in my script IE: $NAME
However the Value in the DB is all in uppercase and contains the users first name and last name
EG:
> echo $NAME
GRAHAM BOYLE
>
What I need is only the... (7 Replies)
I have a package to install and the installation script which does it . The files/directories names in the script are all lower case but the actual package has everything in upper case - file names, directories . I don't want to rename directories and files in the package - it has a lot of them . ... (2 Replies)
HELLO ALL,
URGENTLY NEEDED A SCRIPT TO SELECT AND DELETE LOWER AND MIXED CASE RECORDS FROM A COLUMN IN A TABLE.
FOR EXAMPLE : Table name is EMPLOYEE and the column name is CITY
and the CITY column records will be: Newyork
washington
... (1 Reply)