Linked Questions

3 votes
1 answer
4k views

Is this a Bash bug? $ mkdir test && cd test && echo "a" > "some.file" test$ echo '*' * test$ TEST=$(echo '*') test$ echo $TEST some.file Why is the second output the resolution of *...
Roel Van de Paar's user avatar
3 votes
2 answers
6k views

I know single quotes will not evaluate what's inside, and double quotes will. I often see people quote-quote the dollar sign evaluation. Here are some examples: for i in "${indices[@]}"; do if [ "${a}"...
Sibbs Gambling's user avatar
7 votes
2 answers
548 views

I tend to quote command substitutions as shown below even when assigning their output to a variable: var="$(command)" Is that actually needed though? When does it break? The accepted answer ...
terdon's user avatar
  • 253k
2 votes
1 answer
6k views

I created shell script, that logs into FTP server and renames some directories. I put FTP commands in multiline string like so # !/bin/sh ftp -inv $HOST << EOF user $USER $PASSWORD $COMMANDS ...
Rudolf Gröhling's user avatar
1 vote
1 answer
4k views

I have a small script, which does not give comma separated output when IFS is used, but IFS is mandatory as i need it to read many other value. The output of the below script is odi_server1 ...
Priyanka's user avatar
1 vote
3 answers
961 views

In case of test -e for example: VAR="<this is a file path: /path/to/file/or/dir" test -e $VAR && do_something || do_anotherthing Question: Should I use "$VAR" here?, here I don't like ...
raring-coffee20's user avatar
3 votes
3 answers
1k views

When I do something like this: x="hi echo hello" or x='hi echo hello' Then x will contain the string hi echo hello. But when I don't use quotes: x=hi echo hello Then x will contain the string hi, ...
user268325's user avatar
0 votes
2 answers
430 views

I am writing a bash script for backup with log storage. I use my defined function as follows: logit () { echo " $1 $2 " >> /path/to/log } For logit 'Starting Backup' $(date +'%D ...
beard black's user avatar
1 vote
1 answer
908 views

The alias below works well in zsh when spaces in directory names are \ escaped, but bash doesn't handle them properly. What changes would be required to make them work with bash properly. dum() { du ...
vfclists's user avatar
  • 7,919
0 votes
1 answer
1k views

When I use [0-9] pattern to search for all numbers in a file, whether to use or not use single/double quotes around the pattern produces different outputs. $ cat numbers this line has 3 this line has ...
trainsushi's user avatar
0 votes
1 answer
543 views

I'm getting a very strange output from a script. Here is the line run in the terminal by itself: root@KaliTestBox:~/Desktop/dns1# echo $(whois 13.66.39.88 |head -n 40 |tail -n 28 |tr '\n' ' ') But ...
bashCypher's user avatar
0 votes
0 answers
800 views

I have a music library that I am trying to restore from backup. The original source library was on a QNAP NAS and I copied it over to a CentOS system without any problems. Now that I am trying to copy ...
alpha754293's user avatar
3 votes
3 answers
253 views

I'm aware of several situations where it's unnecessary to use double quotes when expanding a variable in Bash, such as inside [[...]], or when used on the right hand side of a variable assignment. ...
Arronical's user avatar
  • 280
0 votes
0 answers
592 views

The following arguments are valid for docker command: docker ps -f"status=exited" --format 'table {{.Names}}' #output: # jovial_hellman # modest_blackwell So I have created this script docker-ps-...
Marinos An's user avatar
0 votes
1 answer
438 views

Edit: I realized that this has nothing to do with $() it's just the result of using echo *. So I just need a way to escape with echo. I'm writing a script that checks what users don't have passwords ...
Philip Kirkbride's user avatar
0 votes
0 answers
565 views

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 ...
DEKKER's user avatar
  • 998
0 votes
0 answers
534 views

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 ...
Lam Bui Bao's user avatar
0 votes
0 answers
522 views

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 ...
user avatar
0 votes
0 answers
726 views

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=':' ...
BobBarkerMD_atLaw's user avatar
1 vote
2 answers
245 views

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 ...
nima1024's user avatar
0 votes
0 answers
413 views

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 ...
Harshita Singh's user avatar
0 votes
1 answer
370 views

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/...
Wolf's user avatar
  • 1,751
0 votes
1 answer
490 views

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 : "$((...
no_bashell's user avatar
1 vote
1 answer
99 views

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 ...
Ewan Delanoy's user avatar
0 votes
1 answer
177 views

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 ...
Wenhan Xiao's user avatar
0 votes
1 answer
158 views

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-...
BPHusted's user avatar
-5 votes
1 answer
139 views

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 ...
Tim's user avatar
  • 107k
0 votes
0 answers
120 views

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 ...
math's user avatar
  • 119
0 votes
0 answers
95 views

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 ...
CL40's user avatar
  • 111
0 votes
0 answers
73 views

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 |...
傅继晗's user avatar
  • 101

15 30 50 per page
1
2 3 4 5
12