All Questions
22
questions
16
votes
4
answers
5k
views
Does Linux support invoking a program directly via its inode number?
I’m asking because string comparisons are slow, but indexing is fast, and a lot of scripts I write are in bash, which to my knowledge performs a full string lookup for every executable call. All those ...
2
votes
2
answers
2k
views
How do I resolve a relative path in a POSIX shell if readlink/realpath is not available?
If neither utility readlink, nor realpath is available (I think today mostly from GNU coreutils?), what can I use in POSIX shell scripting to resolve a relative path?
There is a realpath C function, ...
1
vote
1
answer
1k
views
Path in script different than actual path
When I echo $PATH in a terminal window, it outputs:
/home/charles/anaconda3/bin:
/home/charles/anaconda3/condabin:
/usr/local/sbin:/usr/local/bin:
/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:
/usr/local/...
1
vote
1
answer
480
views
Why not prepend user directory to PATH?
For user scripts, the usual advice is to append their directory to $PATH in one's .profile:
PATH="$PATH:$HOME/.myscripts" # or .bin or whatever
Apparently that is safer than prepending it: ...
0
votes
1
answer
1k
views
zsh script cannot find commmands [duplicate]
I'm attempting to run this zsh script:
#!/bin/zsh
paths=(
"/docs/"
)
for path in $paths; do
dirsearch.py -u "http://10.129.140.251:8080$path" \
-r --csv-report=&...
0
votes
1
answer
384
views
csh: Changing path in non-interactive login
I want this:
$ ssh nopathcsh@lo 'echo $path'
/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games
To return this:
/usr/bin /bin
I have tried changing and ...
1
vote
1
answer
2k
views
if else statement: check if a path stored in a variable exists [closed]
I have problems with an if statement in my script. I have stored a path in a variable and want to use the if...else statement to check if the file (file1) in the path of the variable exists or not.
...
-2
votes
1
answer
1k
views
Which path is a relative pathname in a shell script relative to? [duplicate]
If a bash script contains a relative path ( to specify a file, a directory, ...), which path is the relative path relative to,
the pathname to the parent directory of the bash script, or
the ...
0
votes
1
answer
604
views
#!/usr/bin/env foo #!vs /usr/bin/foo [duplicate]
Which of the above forms is "better" for running bash, python etc. scripts? Why can't I just do #!$(which foo)? Is it neccecery to specify full path to env? I gather from this answer, that the path /...
3
votes
1
answer
1k
views
read path name with spaces then use the variable into find command
I need to ask the user to provide a path name (which will here have a space) to launch a find command:
read -r -e -p "Folder:" folder
Folder :/mnt/My\ folderX/
echo $folder
gives:
My\ folderX/
But....
6
votes
2
answers
2k
views
* at end of directory path
I have a question about the * character at the end of a directory path in a bash script.
I have a script that's supposed to automatically delete some archives from a server once they get old enough. ...
4
votes
1
answer
16k
views
Safe way to install .sh script in /usr/local/bin?
I want to include correctly the following script in Ubuntu 16.04.
Code
#!/bin/sh
# http://tex.stackexchange.com/a/20886/13173
# $Id: pdf2eps,v 0.01 2005/10/28 00:55:46 Herbert Voss Exp $
# Convert ...
0
votes
1
answer
106
views
Editing the variable PATH
I want to start script just by typing script not the full path of the script for example ~/Desktop/name/script so i tried to edit variable PATH
PATH="$PATH:~/Desktop/name"
in the name folder i have ...
4
votes
2
answers
10k
views
echo $PATH shows path to python scripts, but they cannot be executed
I am new to using the shell, and wanted to create a directory in $HOME where I can put all my python scripts, set a path to that directory, so that I can go into any folder on my Mac and execute those ...
39
votes
4
answers
29k
views
Add path to $PATH if not already in $PATH [duplicate]
I need to add a path in a bash script, but it may be executed several times:
export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/bin/:${PATH}
I don't want that path to be added over and over. How can ...