Linked Questions

282 votes
3 answers
57k views

If you've been following unix.stackexchange.com for a while, you should hopefully know by now that leaving a variable unquoted in list context (as in echo $var) in Bourne/POSIX shells (zsh being the ...
Stéphane Chazelas's user avatar
86 votes
3 answers
283k views

I'm trying to escape the space char for a path in Bash, but neither using a backslash or quotes works. .sh script: ROOT="/home/hogar/Documents/files/" FILE=${ROOT}"bdd.encrypted" DESTINATION="/home/...
Lucio's user avatar
  • 1,317
30 votes
5 answers
11k views

I've read that you need double quotes for expanding variables, e.g. if [ -n "$test" ]; then echo '$test ok'; else echo '$test null'; fi will work as expected, while if [ -n $test ]; then echo '$test ...
CharlesB's user avatar
  • 424
15 votes
6 answers
9k views

Answering this question caused me to ask another question: I thought the following scripts do the same thing and the second one should be much faster, because the first one uses cat that needs to open ...
Mohammad's user avatar
  • 738
6 votes
4 answers
4k views

I have a problem with my script. Prelude Firstly, I have a list, 100 lines-file like that: 100;TEST ONE 101;TEST TWO ... 200;TEST HUNDRED Each line have 2 arguments. For example, first line's ...
rGA145's user avatar
  • 449
6 votes
2 answers
16k views

I looked around for an answer to the question "Can I use an array as an environment variable and then call it from a Bash shell script" and came to the conclusion that it was not "officially" ...
JuanD's user avatar
  • 191
5 votes
5 answers
958 views

This came out of one of my comments to this question regarding the use of bc in shell scripting. bc puts line breaks in large numbers, e.g.: > num=$(echo 6^6^3 | bc) > echo $num ...
goldilocks's user avatar
2 votes
3 answers
1k views

I have seen several times the use of "list context" and "string context". I know and understand the use of such descriptions in perl. They apply to $ and @. However, when used in shell ...
user avatar
1 vote
2 answers
8k views

I need to make a shell script called chExt.sh. that accepts a file extension and then multiple files. It then needs to change the file extensions or state that the file does not exist. ./chExt.sh ...
Josh's user avatar
  • 11
1 vote
1 answer
2k views

I am trying to use cmake and OpenGL to learn computer graphics, and the tutorial included a run.sh file that is supposed to compile/build the cpp programs. Here is the code: #!/bin/bash #calls cd ...
user3150552's user avatar
1 vote
2 answers
434 views

I'm trying to figure out how to use the ${parameter%word} expansion with $@ and $*. It started by trying to make a script to combine pdfs using ghostscript, but I ran into some weird behavior with ...
mangoduck's user avatar
1 vote
3 answers
2k views

I need to write a bash script which will check if it is run as root user ask for the user name check if user exists add new user with password ask for the group name check if this group exists add the ...
Lauro Mike's user avatar
1 vote
2 answers
136 views

For example, I want to find all symlinks that reference to particular binary in all directories that belong to system $PATH. This can be successfully achieved with manual specification of all ...
Anton Samokat's user avatar
-4 votes
1 answer
207 views

This works beautifully in BASH: $ where=/sys/class/backlight/* $ echo $where /sys/class/backlight/intel_backlight However when put in the POSIX script with /bin/sh as an interpreter, this doesn't ...
Artem S. Tashkinov's user avatar
0 votes
3 answers
48 views

my code: execInPath() { prev_dir=${PWD##*/} cd $1 shift res=$($@) cd prev_dir echo res } alias path=execInPath $ path ~ ls gives: bash: cd: prev_dir: No such file or directory (and the files in my ...
Oleg Belousov's user avatar