New answers tagged bash
0
votes
Moving files to a directory with spaces in its name
Quotes tell the shell to treat the enclosed text specially:
Single quotes tell the shell to treat the text literally.
Double quotes allow the shell to evaluate anything starting with $, for example $...
0
votes
How can I add a command to the Bash history without executing it?
To build on @Spiff's answer, you can put the results of the command into the history, not just the command itself. For example, I often like a date time stamp in the history list:
> alias dts='...
1
vote
How to add a pause between lines in a multi-line paste into Telnet terminal on Bash?
My recommendation would be to avoid pasting entirely and to start using expect for CLI automation. While it can do timed delays, one of its main features is being able to wait for a specific reply, ...
2
votes
How to add a pause between lines in a multi-line paste into Telnet terminal on Bash?
Try writing a bash script that prints the telnet commands with the sleep command in between. And pipe the bash script to your telnet shell.
commands.sh
echo 'command 1'
sleep 1
echo 'command 2'
sleep ...
0
votes
RPM none-zero exit code if a package is already installed
Slight necro-bump... but I had a similar requirement when trying to incorporate the installation of multiple packages (ffmpeg and its dependencies) via an ansible playbook using rpm, and this post is ...
0
votes
sdkman installation fails on raspberry pi
I'm running into the same issue, and I think JourneyMan geek has the right of it. I'm fleshing out a new Pironman case install, and can confirm that Raspbian ARM64 is buggy, at least as far as the ...
0
votes
Accepted
How do I change the background color for folders in PowerShell when invoking the "ls" command from WSL Interop?
According to the author of PowerShell WSL InterOP, Environment variables are supported by $WslEnvironmentVariables. And Default parameters are supported by $WslDefaultParameterValues.
So the solution ...
0
votes
Can a linux command auto-login to a specific desktop environment session type
You can enable autologin in sddm, and disable password for sudo. But this might cause security concerns and you will not be able to choose a session.
A display manager is not the best way to achieve ...
0
votes
Accepted
sdkman installation fails on raspberry pi
curl: (22) The requested URL returned error: 404 Not Found
This indicates that the file isn't there. There's not much that can be done at the end user version, though its worth thinking about why ...
1
vote
Get response body and show HTTP code by curl
Even though we are appending http_code as a newline the http_code is showing up as the last line. I think this is because as the man page describes: "-w Makes curl display information on stdout ...
0
votes
bash: How to prevent expand /* in read?
Thanks to all and sorry for my mistakes.
Yes, the problem with globbing (as a special case of expansion?)
With replacements correct code is
read line <<< "/* string */"
echo "${...
2
votes
bash: How to prevent expand /* in read?
The variable actually does hold exactly /*. Your echo prints /bin /boot … because the shell expands unquoted $line just before it runs echo. In Bash expanding an unquoted variable involves word ...
0
votes
bash: How to prevent expand /* in read?
Your problem is actually
globbing,
rather than expansion.
This is a method of solving your question :
$ #disable glob (noglob)
$ set -f
$ echo $line
/*
$ #re-enable glob
$ set +f
Useful reading :
...
1
vote
Accepted
How to nicely print time difference in bash?
There's a builtin variable for this:
#!/bin/bash
./my-long-command.sh
./another-longcommand.sh
echo "Completed, in ${SECONDS}s"
Please, don't suggest creating my own script for this.
Why ...
1
vote
copying tabs from terminal is broken at the text-wrapping edge (the width changes outcome)
This is also the behavior of xterm, which is widely considered as the de facto standard for terminal emulation; and I'm pretty certain that it's also backed by corresponding standards that these ...
0
votes
sha1sum for a directory of directories
If you are in a bash shell, then you can have sha1sum go into specific levels of subdirectories:
sha1sum */*/*
This is a bash feature and apparently there is also a switch to enable global recursion ...
0
votes
sha1sum for a directory of directories
You could use the following rclone command on your directory. It is recursive by default.
rclone sha1sum ./path/to/directory/
The output is compatible with sha1sum.
...
0
votes
Accepted
sudo for just one command IN lost+found folder, not more
Convert your function to a standalone script in /usr/local/bin. Now you have a much simpler problem of needing to grant passwordless 'sudo' access to just that one fixed command, which can be done ...
0
votes
How to mount a partition after resuming from hibernation with systemd
It could be that the mount was carried out in a volatile manner, i.e. it received a termination signal as the script process got terminated and was automatically "re-unmounted". Not sure ...
0
votes
How do I fix "Sudo commands will not succeed by default" on chromeOS Crosh Shell
Do what crosh tells you to. You can access the VT-2 shell with these keys:
(Ctrl-Alt-{F2/Right arrow/Refresh})
Then login with the username chronos.
Then you will be able to use any sudo commands you ...
0
votes
How to give VSCode Flatpak package access to system SDK for Java?
I am using Linux Mint 21.2. I installed VSCode from the build-in flatpak Software Manager and I encounter the same issue.
First, I think it is quite troublesome to explicitly edit VSCode configuration ...
1
vote
Accepted
Tortoise Git not using id_rsa
I finally found the solution!
The problem was that I was using https authentication instead of ssh authentication. This is why it never even tried to access key file.
The solution was to change it to ...
0
votes
What is the windows equivalent for envsubst in linux
Envsubst Equivalent for Windows using PowerShell
There isn't a direct substitute for envsubst built into Windows, but you can achieve similar functionality with PowerShell. Here's a batch script you ...
0
votes
How to pass all arguments to a script called by /bin/bash
I think I found another possible solution. In case you can't or don't want to use sudo/su. This solution works for me.
I know eval is evil. But sometimes you need the help of evil forces :)
#!/usr/bin/...
1
vote
Accepted
Bash script header for virtual machine
Whether it works or not depends entirely on the initial interpreter. It's hacky, yes, but anything else would necessarily be a very OS-specific solution.
If Bash doesn't mind the script ending with ...
0
votes
Make Bash's PS1 show original directory name and not symlink?
Chances are you already have a customized PS1 variable in your ~/.bashrc file and you want to keep your other customizations.
Long story short... just go in ~/.bashrc, find where PS1 variable is ...
-1
votes
2
votes
Accepted
How to pass bash's $@ over ssh accounting for spaces in arguments?
This question: How to execute complex command line over ssh is somewhat related. My answer there concentrates on the case where nothing is expanded locally; you want to expand $@ locally, it makes ...
0
votes
zsh on MacOS catalina 10.15.17
A tool that might work for this is zmv, since it has way to test out a file move command without actually changing anything.
Try these commands in zsh:
autoload zmv
cd /Volumes/.../music
zmv -n '*...
1
vote
How to get out of git in the bash terminal's command line
So in the end this issue comes down to confusion about what the shell is displaying, but we'll walk through it.
Many OS and shell distributors (or their users) may elect to use a "Git Aware" ...
2
votes
Accepted
tail -f nohup.out gives cannot open 'nohup.out' for reading: No such file or directory
From man 1 nohup [emphasis mine]:
[…] If standard output is a terminal, append output to nohup.out if possible, $HOME/nohup.out otherwise. If standard error is a terminal, redirect it to standard ...
0
votes
macOS ssh ignoring UserKnownHostsFile option
This might not be related to MacOS. The parameters like StrictHostKeyChecking, UserKnownHostsFile and CheckHostIP are only related to the target host that you're connecting to. In your case, it's ip. ...
1
vote
Accepted
Name of script that allows you to move files by editing their paths in a text editor?
vidir allows you to edit filenames in a text editor. To choose an editor set the EDITOR variable. In Debian or Ubuntu vidir is in the moreutils package.
This is what vidir can do (excerpt from man 1 ...
0
votes
Find and replace string in a file using 'sed' or 'awk'
The problem is with your command is that sed -i replaces in the file, but the awk outputs the captured strings. You can solve it with @slhck's solution to simply replace every .1 with .+1.0, but to be ...
2
votes
Netstat dosent exist in my debian linux bash shell
Most modern Linux distros have replaced netstatwith ss, so you might want to check if what you were trying to do with netstat can equally be achieved with ss.
For most common use cases both programs ...
1
vote
Netstat dosent exist in my debian linux bash shell
There is no reason why netstat should be present in your system since it's not one of POSIX-defined utilities. You can check out the current list of those here.
Because it's not in POSIX (which is a ...
1
vote
What are all of the globs I can use with grep in bash?
There is a difference between the bash builtin parameter expansion called glob, and what grep can understand as a search input.
Typical glob use is the *, to expand to any string in it's place that ...
0
votes
How to write current network speed
Install nload and parse (grep + sed + awk , etc) its output and write it your log file.
For reference, read this article: https://www.tecmint.com/nload-monitor-linux-network-traffic-bandwidth-usage/
0
votes
Split window programmatically with iTerm?
I recently created a CLI tool to split panes, it uses the python API rather than AppleScript as AppleScript API is deprecated
Repo
Install:
pip3 install iterm-pane-spliter
iterm-pane-spliter <json-...
1
vote
Accepted
bash scripts not loading any of ~/.bash*
Please read the following section of the manual: 6.2 Bash Startup Files. It describes what files get sourced, depending on the way of invoking bash. When bash interprets a script, it does not source ...
1
vote
Different behaviour of the find (parameter not correct) on *nix and windows (ming32) systems
FIND: Parameter format not correct
explanation:
The find command is a powerful command used to search for files in a file system. It is available on Cygwin and Windows, but there are some differences ...
0
votes
Fit 2 A5 pdf into ONE PAGE A4 Landscape
Booklet printing is a variation on N-UP and for 16 pages "should be simple"
There are many complex ways I have described using LaTeX as saddle stitches method for upto 32 pages here adapted ...
1
vote
Accepted
CentOS 9 Stream SSH with PuTTy - multiline commands
It's an update to the bash shell, yes. Instead of always processing input line by line, it now requests the terminal (PuTTY in this case) to use "bracketed paste" mode and indicate when text ...
1
vote
Fit 2 A5 pdf into ONE PAGE A4 Landscape
The texlive-extra-utils packages has a a5toa4 tool that does exactly what you want.
0
votes
Echo multiple lines of text to a file in bash?
My script to save multiline into a .csv file:
#! /bin/bash
while [ 1 ]
do
sleep 1s
str="\""$(date)"\""
echo ${str} >>333.csv
# begin add next ...
0
votes
error when I execute the command source ~/.bashrc
If your shell is zsh, make your edits in ~/.zshrc instead of .bashrc.
When you're done, save the file using :wq (assuming you're using vim) and run this command:
source ~/.zshrc
Remember to remove ...
1
vote
Make a Mac sound an alarm when it can't ping a server?
Just do ping -A 1.1.1.1 and it will blip on every failed request.
lowercase a will ping for every successful request, instead (ping -a 1.1.1.1)
> man ping
...
-A Audible. Output a bell (...
1
vote
Accepted
How to execute three terminal scripts in three new tabs from Applescript?
You can just send the key command to open a new tab, then direct your script to this new tab. You don't need to activate each time, once it's at the front.
Here I've substituted echo hello so it's ...
0
votes
tmux exits with [exited] 1;2c on macOS catalina
pkill tmux works for me.
I'll explain what I encountered, not because of reinstallation or upgrade. I hope that can help someone here.
I tried to set an option at .tmux.conf on Macos system.
set-...
0
votes
Accepted
How to parse upload and download speed with ifstat and printf?
You don't need awk for this:
printf "Download %.0f KB/s Upload %.0f KB/s\n" $(ifstat 1 1 | tail -n1)
Top 50 recent answers are included
Related Tags
bash × 11574linux × 4842
command-line × 1584
shell × 1543
macos × 1001
terminal × 982
ubuntu × 736
ssh × 670
unix × 610
bash-scripting × 549
script × 515
shell-script × 501
sed × 358
zsh × 311
windows × 297
grep × 292
cygwin × 264
git × 255
find × 245
windows-subsystem-for-linux × 234
mac × 222
windows-10 × 215
awk × 212
environment-variables × 209
cron × 196