Linked Questions
338 questions linked to/from When is double-quoting necessary?
0 votes
0 answers
565 views
write terminal output to file while keeping new lines [duplicate]
when I call env to see the environment variables it shows nicely with new lines: $ env SHELL=/bin/sh EDITOR=vi PWD=/home/user ... but when I want to store this to a file the new lines get ...
0 votes
0 answers
534 views
How to get zsh to not recognize the asterisk in apt-get [duplicate]
I am currently on Pop!OS 20.04, and after installing zsh and setting it as my default shell, when installing apps by using apt-get like follows, zsh says no matches found: sudo apt-get install ...
0 votes
0 answers
522 views
Moving a file to a directory with spaces in the name [duplicate]
The destination directory is a directory with spaces in the name: /opt/config/Sn Lk Now I wrote a script which moves a file from my directory to this directory, but the move fails Although the echo of ...
0 votes
0 answers
726 views
Confusing behavior when using IFS and read [duplicate]
line="touch : touch : test.txt" IFS=':' read scr cmd <<< "$line" echo $scr echo $cmd output: touch touch : test.txt line="touch : touch : test.txt" IFS=':' ...
1 vote
2 answers
245 views
Passing options by variables in bash does not work [duplicate]
I encountered a very strange behavior when running below command, let me explain the issue: Consider this simple bash script: #!/bin/bash zip -r /var/backup.zip /var/www -x /ignore_dir_1/\* It ...
0 votes
0 answers
413 views
how to remove a file in Jenkins through Execute Shell [duplicate]
this is the console output of Jenkins' build. Here, you could see that the file Oct Release SQL.txt is present in the path but when I am deleting it by using rm Oct Release SQL.txt, it is not able to ...
0 votes
1 answer
370 views
How to copy a file to a path with a space in it in Bash Script? [duplicate]
Sample script to copy /tmp/template.txt file to any directory as specified in $1. copy_script.sh if [ $# -eq 0 ]; then echo No Argument echo "Usage: $0 <path>" else cp /tmp/...
0 votes
1 answer
490 views
How do I make two echos output to a text file on separate lines [duplicate]
So I have a shell script math.sh which takes a number as an argument and echos one added to it and one subtracted from it: #!/bin/bash echo "Add: "$(($1 + 1)) echo "Subtract : "$((...
1 vote
1 answer
99 views
Prevent quote expansion in user-made function [duplicate]
I have the following bash function : tg() { git add -A && git commit -m $1 && git push } But it seems not to work : $ tg "create index for users" error: pathspec 'index' did not ...
0 votes
1 answer
177 views
Print awk function out to new line everytime [duplicate]
part of my code is as below : output=$(cat databaselog | awk '{print $9,$1,$2,$6}' ) echo $output >> savedfile Output will be something like this , saved in a new file called savedfile name1 ...
0 votes
1 answer
158 views
How to pass content from .txt file as argument for bash command after an equal sign [duplicate]
Instead of typing in the content of a public key I want to pass the content of it as an input. The command used is ipa user-mod user --sshpubkey='ssh-rsa AAA ........' This work. When I do ipa user-...
-5 votes
1 answer
139 views
Why is unquoted $PATH containing whitespaces safe in an assignment? [duplicate]
What does the following from https://unix.stackexchange.com/a/154290/674 mean? In general, in shells other than zsh, $PATH outside double quotes breaks when the value contains spaces or other ...
0 votes
0 answers
120 views
netcat redirects stderr to stdout then variable losing newlines [duplicate]
I am working on a script to parse a file containing a list of IP addresses and ports then do a bunch of test on the ports with netcat. The port argument can be a single port, a list of ports, or a ...
0 votes
0 answers
95 views
Prevent string splitting in argument to readlink [duplicate]
I am writing a small script to symbolically link configuration files from my dotfiles directory to another one. I do not have control over the file names and unfortunately one of them is causing me a ...
0 votes
0 answers
73 views
Why command `cat test.log |while read line; do echo $line ; done` would compress whitespace? [duplicate]
I have a file named "test.log" with contents: 2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 [kthreadd] Then I use while-read command to process it: cat test.log |...