15
votes
Understanding "side effect", or multiple commands within one command?
The : is called the null command. You can find its documentation in man bash:
: [arguments]
No effect; the command does nothing beyond expanding arguments and performing any specified redirections....
3
votes
Accepted
Extracting text preceding a particular string
This truncates the lines of input at the first occurrence of the string .nc:
sed 's/\.nc.*//'
(Note that the dot in .nc must be escaped as it would otherwise match any single character. The .* after ...
2
votes
Understanding "side effect", or multiple commands within one command?
Is the command $(( i += 1 )) called the "side-effect" of :?
No. Incrementing the value of i is the side-effect of evaluating the expression (not a command) $(( i += 1 )).
In other words if ...
2
votes
Accepted
How can I encrypt a password in a bash script?
Short answer: No, you cannot.
Long answer: Shell scripts are human-readable files. As per the suggestion below, your question does not make proper sense.
Suggestion: Use Public Key Authentication, see ...
2
votes
Accepted
Run if conditions in Parallel
To serialise those outputs (and errors), you'd have to save at least one of them temporarily:
#! /bin/zsh -
ret=0
umask 077 # for temp files that we recreate
if findmnt --source UUID=309689b5-ea5c-...
1
vote
Accepted
What is the difference between .shrc and .profile?
The closest thing to the Bourne shell, which wasn't really an open source program and cannot be found on pretty much any operating system nowadays, is the Heirloom Bourne shell from OpenSolaris, which ...
1
vote
pass variable to find files on remote server using newermt option
Remember ssh runs a shell to interpret the concatenation with space of its arguments. That * needs to be quoted for the local shell and also for the remote shell, but -name '*' doesn't make much sense ...
1
vote
How to sort data which is having 180 million lines of data in the file?
GNU sort can sort files larger than what would fit in your RAM.
It does that by sorting a part of your input that does fit, writing the result to a temporary file, moving on to the next input part, ...
1
vote
Extracting text preceding a particular string
I suspect what you really want is to find .nc either followed by . or at the end of the line, and that you want to match on the first occurrence of that (as opposed to the last occurrence) on each ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
shell-script × 16193bash × 6660
shell × 2350
linux × 1877
scripting × 1124
text-processing × 1096
awk × 980
sed × 825
files × 489
grep × 469
command-line × 405
ssh × 373
find × 359
variable × 327
ubuntu × 299
cron × 280
zsh × 278
regular-expression × 238
quoting × 228
ksh × 220
pipe × 217
io-redirection × 206
terminal × 199
date × 195
rename × 175