All Questions
578 questions
0
votes
2
answers
97
views
How to redirect output from a program that waits for input
Following this post I created my own version of the script, with the difference that user and password are forwarded from the environment variables:
#!/bin/zsh
pamtester login $user authenticate <&...
0
votes
2
answers
85
views
How to analyse a number of different datasets with a script and save the output for each dataset in a different new directory?
I am interested in analysing 50 different datasets with a script and saving the output of each of the 50 analyses in 50 different corresponding directories. To avoid doing this manually, how could ...
0
votes
0
answers
19
views
zsh variable expansion [duplicate]
I'm a bit of a noob with *nix and sh vs bash vs zsh specifically. Can someone explain this syntax with shell variables? What syntax do I need to use to get a filename pattern held in a variable to ...
0
votes
0
answers
27
views
Variable Argument Processing - zsh vs. bash [duplicate]
I ran across a problem in one of my scripts when I changed it from bash to zsh. Here is the behavior in bash:
bash-5.2$ X="-v1d -v+1d"
bash-5.2$ echo $X
-v1d -v+1d
bash-5.2$ date $X
Mon Dec ...
0
votes
1
answer
53
views
zsh, .bash_profile, and aliases
I have a script downloaded from the Internet, the beginning of which looks like this:
echo "alias myip='curl -s https://api.ipify.org/'" >> ~/.bash_profile
echo "alias myiplookup='...
3
votes
0
answers
76
views
Deleted file on ramdisk is not purged while in a loop
I have a ramdisk mounted to /ram which typically holds temporary data that I know don't need saved. The filesystem of the ramdisk is f2fs, created by zram-generator with this configuration:
# /etc/...
1
vote
0
answers
36
views
Going to the direcory of a file as fast as posible [duplicate]
Is there a way to get to the path of a file as fast as possible and in the least amount of keystrokes.
Context:
Type cd and then paste the path of a file and then have to go back and hit backspace ...
0
votes
1
answer
119
views
To move files only; To copy folders only
Tested in Bash and Zsh:
copy nondot files | cp ~/dir1/* ~/dir2/
copy dot files | cp ~/dir1/.* ~/dir2/
copy both nondot and dot files | cp ~/dir1/{.,}* ~/dir2/
...
-1
votes
2
answers
90
views
In bash/zsh, how to compare the metadata in two directories including . and excluding .. and the contents inside subdirectories?
Let's say that in a script, you have a directory $1 and its copy $2 and you'd like to compare the metadata (names, permissions, sizes, full modification dates, …) of the files and directories inside ...
5
votes
1
answer
357
views
printf in Zsh does not shell escape exclamation mark
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/...
2
votes
0
answers
47
views
Can't unalias then redefine as a function in the same conditional [duplicate]
Here is a simplified implementation of an issue in my bash/zsh aliases file:
alias foobar='echo bar' # this is out of my control
if true; then
unalias foobar
echo we got inside the conditional
...
0
votes
0
answers
116
views
How to show path after cd command with CDPATH set?
I came across this question and showing the current path after cd is exactly what I'm looking for.
However, I can't manage to get this behavior.
What I've tried is this:
export CDPATH='.:/home/...
0
votes
0
answers
795
views
zsh module command not found
I recently switched from bash to zsh on CentOS 7. I am using oh-my-zsh
I'm encountering an issue where modules cannot be loaded from a script. When I manually load the module in the login shell, it ...
0
votes
2
answers
129
views
mv multiple files on Linux vs. on Mac
To move multiple files on Linux, one could use:
mv -t DESTINATION file1 file2
Whereas on macOS it is
mv file1 file2 DESTINATION
Why is this difference? Is this a Bash vs. Zsh thing, or older vs. ...
0
votes
2
answers
188
views
:q to quit from less and man. Are there other colon-commands in Bash/Zsh?
To quit from man or less, we use :q, like in Vim. But where can I read about this command and probably other similar commands (maybe :w, for example) in Bash or Zsh documentation? help q, help :q, ...