Could anyone help me in writing a single line code by either using (sed, awk, perl or whatever) to extract a specific path from the PATH environment variable?
for eg: suppose the PATH is being set as follows
I need to check whether the string "java" is there (consider "java" appears exactly one time for the time being), if it does exist I need to extract the path "/usr/bin/java".
Note: java path may appear at any position (i.e) it may be the first or the last path or appear in middle of the PATH setting. So my code should be efficient in handling all these
Hi:
I have a requirement as below:
I have some standard Unix commands modified and kept them in a directory say /usr/clsh/bin. For example I have a script named "ls" kept here which is modified version of "ls" (say it always gives long listing i.e. ls -l).
When any user logs on and types... (2 Replies)
Hi,
I have a environmental variables,
ORACLE_HOME=/u01/oracle/ORCL/db/tech/10.2.0
ORACLE_SID=ORCL
Now I need to create a variable and need to extract some part from ORACLE_HOME. I need to get the path from ORACLE_HOME till ORACLE_SID as /u01/oracle/ORCL. I may need to check also... (6 Replies)
Hi
I need a script which will remove a path from PATH environment variable. For example
$echo PATH
/usr/local/bin:/usr/bin:test/rmve:/usr/games
$echo rmv
test/rmve
Here I need a shell script which will remove rmv path (test/rmve) from PATH... (9 Replies)
I make this script that uses "strace" to trace programs. The script looks for files that the program opens. It looks like this
open("/lib/libtermcap.so.2", O_RDONLY) = 3
open("/dev/tty", O_RDWR|O_NONBLOCK|O_LARGEFILE) = 3
I want to extract the path without the quotes, preferably using grep and... (4 Replies)
Hello Folks,
I want to append a path in user's PATH variable which should be available in current session.
Background
Numerous persons will run a utility.
Aim is to add the absolute path of the utility the first time it runs so that next runs have the PATH in env & users can directly run... (6 Replies)
Hi I'm trying to select text between two lines, I'm using sed to to this, but I need to pass variables to it. For example
start="BEGIN /home/mavkoup/data"
end="END"
sed -n -e '/${start}/,/${end}/g' doesn't work. I've tried double quotes as well. I think there's a problem with the / in the... (4 Replies)
Hi All,
Can you please provide some pointers to move files from Base path to multiple paths in efficient way.Folder Structure is already created.
/Path/AdminUser/User1/1111/Reports/aaa.txt to /Path/User1/1111/Reports/aaa.txt
/Path/AdminUser/User1/2222/Reports/bbb.txt to... (6 Replies)
Currently I am using this laborious command
lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}'
Would like to know if there is any shorter method to get this mapping of... (2 Replies)
Hello,
I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies
LEARN ABOUT LINUX
shtool-path
SHTOOL-PATH.TMP(1) GNU Portable Shell Tool SHTOOL-PATH.TMP(1)NAME
shtool-path - GNU shtool command dealing with shell path variables
SYNOPSIS
shtool path [-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename] [-m|--magic] [-p|--path path] str [str ...]
DESCRIPTION
This command deals with shell $PATH variables. It can find a program through one or more filenames given by one or more str arguments. It
prints the absolute filesystem path to the program displayed on "stdout" plus an exit code of 0 if it was really found.
OPTIONS
The following command line options are available.
-s, --suppress
Supress output. Useful to only test whether a program exists with the help of the return code.
-r, --reverse
Transform a forward path to a subdirectory into a reverse path.
-d, --dirname
Output the directory name of str.
-b, --basename
Output the base name of str.
-m, --magic
Enable advanced magic search for ""perl"" and ""cpp"".
-p, --path path
Search in path. Default is to search in $PATH.
EXAMPLE
# shell script
awk=`shtool path -p "${PATH}:." gawk nawk awk`
perl=`shtool path -m perl`
cpp=`shtool path -m cpp`
revpath=`shtool path -r path/to/subdir`
HISTORY
The GNU shtool path command was originally written by Ralf S. Engelschall <rse@engelschall.com> in 1998 for Apache. It was later taken
over into GNU shtool.
SEE ALSO shtool(1), which(1).
18-Jul-2008 shtool 2.0.8 SHTOOL-PATH.TMP(1)