Linked Questions

213 votes
6 answers
341k views

$ ls -l /tmp/test/my\ dir/ total 0 I was wondering why the following ways to run the above command fail or succeed? $ abc='ls -l "/tmp/test/my dir"' $ $abc ls: cannot access '"/tmp/test/my': No such ...
Tim's user avatar
  • 107k
19 votes
2 answers
110k views

Many questions like 'How to type the double-quote char (")?' are being asked, and we don't want to clutter our community with the same answer (Type it as \" if not enclosed in 's, " if enclosed in 's.)...
EKons's user avatar
  • 974
29 votes
2 answers
7k views

ssh has an annoying feature in that when you run: ssh user@host cmd and "here's" "one arg" Instead of running that cmd with its arguments on host, it concatenates that cmd and ...
Stéphane Chazelas's user avatar
6 votes
5 answers
2k views

I want to download a list of files from a SSH server, then put it in some kind of container (like a tar file) and finally encrypt it (e.g. with openssl). The point of putting it into a archive is to ...
Xali's user avatar
  • 61
7 votes
5 answers
2k views

Given any two absolute Unix path specs1, one could decompose each spec as the concatenation of a longest common prefix and a specific suffix. E.g., /abc/bcd/cdf -> /abc/bcd + cdf /abc/bcd/chi/...
kjo's user avatar
  • 16.4k
7 votes
3 answers
710 views

The question may sound quite complicated, but in fact it is not! Consider: % f() { echo "$@"; } % f a a % f cmd -o"value with space" cmd -ovalue with space % f cmd -ovalue with ...
U. Windl's user avatar
  • 1,777
1 vote
5 answers
11k views

With bash, I'm running this: declare -p | grep 'declare -- ' That prints whole lines. I want to print those same lines, but I wanted to exclude the match itself. i.e., Can I do ... | grep pattern | ...
Daniel Kaplan's user avatar
1 vote
5 answers
5k views

I have an .env file and need to copy to an .env.sh file. The command exports to .env.sh file: scriptPath=$(dirname "$(readlink -f "$0")") printenv | sed 's/^\(.*\)$/export \1/g' &...
Công Tuấn's user avatar
4 votes
4 answers
7k views

In a Bash script, I pass a command with arguments. This works fine, except when the command includes a redirection. In that case, the redirection character is treated as an ordinary character. $ cat ...
k314159's user avatar
  • 533
0 votes
2 answers
2k views

I have a directory named data. Inside data there is one directory samples which has more than 50 directories and there is one shell script testing.sh inside data. The setup looks like below: data |...
beginner's user avatar
  • 277
5 votes
1 answer
500 views

In Zsh 5.9, we can use printf to shell escape a string: $ printf '%q' 'One! Two' One\!\ Two This produces the correct output of escaping the ! and the space. Now let’s make it as a script: #!/bin/...
user137369's user avatar
4 votes
2 answers
556 views

For performance reasons, I want to use find to list a large number of files, but also include a counter on each line. The following is what I have so far: local root_dir="." local ...
Peter Grill's user avatar
  • 1,673
5 votes
2 answers
739 views

This is specifically about bash's declare - the general case is pretty exhaustively dealt with in this answer (which mentions "the typeset/declare/export -p output of ksh93, mksh, zsh" but ...
muru's user avatar
  • 78.4k
1 vote
5 answers
365 views

I have a hierarchy of directories. Some directories do not contain files and they only contain other directories. Some contain files. For example: - movies - 2022 - action - movie.mp4 ...
Saeed Neamati's user avatar
0 votes
2 answers
816 views

I wrote a script that collects application logs on local machine and then from remote machine. It has variable oldlogsdate which reads the date of logs I want to collect. For example, if I enter Apr ...
OmiPenguin's user avatar
  • 4,398

15 30 50 per page