Note as you want ${PATH} to be expanded by the bash script you should protect if from being expanded by you current shell. An easy way to ensure this is to enclose the command within single quotes for example:
This User Gave Thanks to Chubler_XL For This Post:
hi,
i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
Hello All. I suspect that this will be a clear noob question, but I haven't been able to figure it out using the usual methods, so I turn to you.
I've written a script to create input files for the quantum chemistry program NWCHEM. Generally you create an input file and then execute it by... (12 Replies)
Server: IBM p770
OS: AIX 6.1 TL5 SP1
When one of our develoeprs types "bash" on the command line to switch shells, it hangs. For some reason, two bash processes are created....the first bash process spawns a second bash process in the same console, causing a hang. Anyone have any idea what... (2 Replies)
Hi all. On X11 I'm on a shell ...shell_1 (/bin/bash). From here I want to open another shell window shell_2 who executes commands like "ls -l" or programs like ". /program"... so the "result" of commands shows in shell_2 window and not in shell_1. Is that possible ? (4 Replies)
#!/bin/bash
#...
for i in `ls -c1 /usr/share/applications`
do
name="cat $i | grep ^Name= | cut -d = -f2"
echo $name
#...
done
Now inside name as output is present:
while i want only the result of the command.
Ideally i would like obtain that information using only bash ... or... (8 Replies)
I am having trouble with bash. I am trying to put a command in an if statement and then compare it to a string.
This works perfectly.
echo $(ipcs | grep Shared | awk '{print $2}')When I put it in an if statement I get some problems.
$ if ; then echo expression evaluated... (10 Replies)
hello, i am facing some issue. I am using a simple bash script that via sshpass put a command into router. Now, problem is that i have a file and commands into it.
sshpass -p $pass ssh -o $log -n $user@$h /ip address set address=10.0.0.1/24
so if I have that command ip address set ... (0 Replies)
I use plink.exe to automate remote commands that return data to Windows machines. This works well on newer servers running Red Hat since the commands were developed for bash and the designated user's login shell is bash. I need to also support older servers which are running Solaris 10 but the... (5 Replies)
Hi everyone,
I want to kill process through the web, so I create html page with single bottom that run kill command in shell script with CGI.
Here is html code:
<td><form METHOD="GET" action="http://IP:port/cgi_bin/script.cgi" > <input type="submit" value= "Submit" > <INPUT name="q"... (7 Replies)
Hi,
I downloaded source code file from The GNU website and changed the source code of ls.c file, added printf command to it. It worked fine. Then, I deleted the printf command, saved the file and ran the command 'make sudo && make install' closed the terminal and printf statement went away.
I... (1 Reply)
Discussion started by: akanksha1509
1 Replies
LEARN ABOUT SUSE
which
WHICH(1) General Commands Manual WHICH(1)NAME
which - shows the full path of (shell) commands.
SYNOPSIS
which [options] [--] programname [...]
DESCRIPTION
Which takes one or more arguments. For each of its arguments it prints to stdout the full path of the executables that would have been exe-
cuted when this argument had been entered at the shell prompt. It does this by searching for an executable or script in the directories
listed in the environment variable PATH using the same algorithm as bash(1).
This man page is generated from the file which.texinfo.
OPTIONS --all, -a
Print all matching executables in PATH, not just the first.
--read-alias, -i
Read aliases from stdin, reporting matching ones on stdout. This is useful in combination with using an alias for which itself. For
example
alias which='alias | which -i'.
--skip-alias
Ignore option `--read-alias', if any. This is useful to explicity search for normal binaries, while using the `--read-alias' option in
an alias or function for which.
--read-functions
Read shell function definitions from stdin, reporting matching ones on stdout. This is useful in combination with using a shell func-
tion for which itself. For example:
which() { declare -f | which --read-functions $@ }
export -f which
--skip-functions
Ignore option `--read-functions', if any. This is useful to explicity search for normal binaries, while using the `--read-functions'
option in an alias or function for which.
--skip-dot
Skip directories in PATH that start with a dot.
--skip-tilde
Skip directories in PATH that start with a tilde and executables which reside in the HOME directory.
--show-dot
If a directory in PATH starts with a dot and a matching executable was found for that path, then print "./programname" rather than the
full path.
--show-tilde
Output a tilde when a directory matches the HOME directory. This option is ignored when which is invoked as root.
--tty-only
Stop processing options on the right if not on tty.
--version,-v,-V
Print version information on standard output then exit successfully.
--help
Print usage information on standard output then exit successfully.
RETURN VALUE
Which returns the number of failed arguments, or -1 when no `programname' was given.
EXAMPLE
The recommended way to use this utility is by adding an alias (C shell) or shell function (Bourne shell) for which like the following:
[ba]sh:
which ()
{
(alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@
}
export -f which
[t]csh:
alias which 'alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
This will print the readable ~/ and ./ when starting which from your prompt, while still printing the full path when used from a script:
> which q2
~/bin/q2
> echo `which q2`
/home/carlo/bin/q2
BUGS
The HOME directory is determined by looking for the HOME environment variable, which aborts when this variable doesn't exist. Which will
consider two equivalent directories to be different when one of them contains a path with a symbolic link.
AUTHOR
Carlo Wood <carlo@gnu.org>
SEE ALSO bash(1)WHICH(1)