Skip to main content
Share Your Experience: Take the 2024 Developer Survey
3 votes
Accepted

ShellCheck does not detect error? How to fix my snippet?

You have two syntax errors. First, either a semicolon or a newline is required. This is wrong1: if condition; then command1 else command2; fi But these are correct: if condition; then command1; else ...
terdon's user avatar
  • 243k
3 votes

How to edit selected words while preserving white spaces and newlines

For text processing, use a text processing utility, not a bash loop. To title-case the first sequence of non-whitespace on a line and all those other than a, the and in, you can use perl: perl -pe ' ...
Stéphane Chazelas's user avatar
2 votes

How to edit selected words while preserving white spaces and newlines

Assumptions: You want to take a generic text, multi-line and make all except specified words to be upper case. Keeping the newlines and spacing. Assuming singular spaces between words. As you cannot ...
Robin Hellmers's user avatar
2 votes

Bash script: echo output of variable and write to file

#!/bin/bash if [ "$(grep A /home/user/scripts/test01.txt)" = "A, B, C, D" ]; then cp /home/user/scripts/test02.txt /home/user/scripts/test01.txt echo "Setting configured.&...
JayCravens's user avatar
2 votes

Bash script: echo output of variable and write to file

#!/bin/bash # -q makes grep not give any output AND quit after finding a first match # if grep -q 'A, B, C, D' /home/user/scripts/test01.txt then cp /home/user/scripts/test02.txt /home/user/...
humance's user avatar
  • 31
2 votes

Best way to swap filenames

The GNU coreutils mv command now (since version 9.5) has an option --exchange to cover this! see mv: new option --exchange There is now also a exch utility in util-linux since version 2.40.
书禾日木子's user avatar
2 votes

What does a leading colon in a sh script line means?

On a macOS Sonoma, where GNU Bash 3.2.57 (an old version) is used as sh, the invoked help command issued from within sh (which is that old version of bash) describes it as: "No effect; the ...
PRouleau's user avatar
  • 151
1 vote

Crontab run after deleting a file

No, don't delete your crontab.sh file but if you want to remove the execution just remove the according line while using crontab -e it will edit the crontab using your preferred EDITOR. You can backup ...
admstg's user avatar
  • 736

Only top scored, non community-wiki answers of a minimum length are eligible