Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Can anyone convert this bash script to a csh script? Essentially what this script does is it takes an a directory as an arguement and appends that to the LD_LIBRARY_PATH in the .cshrc file and sources the file.
Here's the script:
------------------
#!/bin/sh#
# Ok, first off - make sure we were invoked with an argument. That
# argument will be the directory we want to add to LD_LIBRARY_PATH
#if [ "$#" -ne "1" ]
then
echo "Usage: $0 dirName"
exit 1
fiDIR="$1"
#
# Is 'DIR' a directory?
#if [ -x $DIR ]
then
: # yep
else
echo "$DIR does not exist or is not a directory"
exit 1
fi#
# Ok, do they have a .bashrc file?
#BASHRC="~/.bashrc"
if [ -f $BASHRC ]
then# yep, they do - see if there's an LD_LIBRARY_PATH entry in it
# already. Look for a line with 'LD_LIBRARY_PATH' in it
# but make sure it isn't a comment ...RESULT=`grep -n LD_LIBRARY_PATH $BASHRC | grep -v "^[ ]*#"`
if [ "$RESULT" = "" ]
then
# no LD_LIBRARY_PATH, just tack it onto the end of their file ...echo "export LD_LIBRARY_PATH=$DIR" >> $BASHRC
else# Ok, grab out the line number and the current value of
# LD_LIBRARY_PATH from $RESULTLINE_NUMBER=`echo $RESULT | awk -F: '{ print $1 }'`
VALUE=`echo $RESULT | sed 's/.*=//'`THE_LINE="export LD_LIBRARY_PATH=$DIR:$VALUE"
if [ "$LINE_NUMBER" = "1" ]
then
echo $THE_LINE > /tmp/$$.txt
cat $BASHRC | sed -n '2,$p' >> /tmp/$$.txt
else
BEFORE=`expr $LINE_NUMBER - 1`
AFTER=`expr $LINE_NUMBER + 1`cat $BASHRC | sed -n "1,$BEFORE"p > /tmp/$$.txt
echo $THE_LINE >> /tmp/$$.txt
cat $BASHRC | sed -n "$AFTER,$"p >> /tmp/$$.txt
fimv /tmp/$$.txt $BASHRC
fi# source that sucker to life ...
. $BASHRC
fi

![]() |
SU Command doesn't work
|
rename all files with an ...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |