On 4/26/23 21:22, Linux for blind general discussion wrote:
Okay, so I've been using a ~/.bash_profile file with the following contents:
rm -f ~/.bash_history
$ history -c
export PS1='$(tty | sed 's#^/dev/tty##')\$'
export PATH=~/Programming/bash-scripts:$PATH
${PATH} is better when you create a string
Also, I have some scripts to automate sshing into some remote hosts or
mounting the remote filesystems locally, and part of it involves
creating a mounttt point that needs to be chown to my user. Is there a
shell variable I can use to make these scripts work for any user
instead of needing to edit the script to use the name of the user I'm
logged in as?
$ USER_NAME=$USER sh try.sh
$ cat try.sh
echo $USER_NAME
$ sh try.sh $USER
$ cat try.sh
echo $1
$ sh try.sh
echo $USER
$ try.sh -u $USER
$ cat try.sh
#!/bin/sh
while getopts ':u:' options; do
case $options in
u)
user=$OPTARG
;;
*)
printf "Error: option %s not recognized at index %s\n"
$OPTARG $((OPTIND-1)) >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
echo $user
HTH.
--
John Doe
_______________________________________________
Blinux-list mailing list
Blinux-list@redhat.com
https://listman.redhat.com/mailman/listinfo/blinux-list