Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

Not an exact answer, but ran into this trick. If the string you're looking for comes from "a command" then you can actually store the command in an env. variable and then execute it every time for the if statement, then no brackets required! For example this command, which determines if you're on debian: grep debian /proc/version full example: ...


0

nano /etc/profile Add these line to the end of the file: export JAVA_HOME=/opt/jdk-12.0.1 export MAVEN_HOME=/opt/apache-maven-3.6.1 export M2_HOME=/opt/apache-maven-3.6.1 export M2=/opt/apache-maven-3.6.1/bin export PATH=$JAVA_HOME/bin:$M2:$PATH Save the file. Restart or use the below command: source /etc/profile Test your ...


0

Following off of what others said, the set manual is a good resource. I put: #!/usr/bin/env bash exec 1> command.log 2>&1 set -x At the top of scripts I wish to keep going, or set -ex if it should exit upon error.


0

Resolved. Via this: ssh jenkins@srv1 "mkdir D:\myfolder\\$test" So, we have to add \ before our variable


1

One method that comes to mind is to iterate over the list of mountpoints and see how many files are present under each one. A value of 1 probably means the filesystem isn't mounted (and only the directory itself is present). This strategy won't work if the mountpoints are nested, however. By "nested" I mean mountpoints like: /mnt/server1/share1 /mnt/...


2

Combining the test command with the -d flag and checking to see if the mount exists per this question: #!/bin/bash mount="/fileserver" if mountpoint -q "$mount" && test -d /path/to/share; then cp -ru /path/to/files /. -t /path/to/share fi Edited per Michael Hampton's comment.


1

At least bash-completion 2.8 and later enable option to place local Bash completions in directory ${BASH_COMPLETION_USER_DIR-~/.local/share/bash-completion}/completions The completion file names or symbolic link names must match the respective command names. These completions are loaded only on demand. Completions stored in file ~/.bash_completion are ...


0

Another approach: # Install. brew install coreutils # Use the GNU variant. grealpath --help


0

It seems that with newer versions of sudo this problem is solved: On my gentoo laptop: $ sudo -k $ echo "$PW" | sudo -S -p "" whoami root $ sudo --version Sudo version 1.8.25p1 Sudoers policy plugin version 1.8.25p1 Sudoers file grammar version 46 Sudoers I/O plugin version 1.8.25p1 On older Ubuntu machines you can simply redirect the prompt to /dev/null:...


Top 50 recent answers are included