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....
terdon's user avatar
  • 232k
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 ...
Kusalananda's user avatar
  • 316k
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 ...
hobbs's user avatar
  • 869
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 ...
Vlastimil Burián's user avatar
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-...
Stéphane Chazelas's user avatar
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 ...
JdeBP's user avatar
  • 65.8k
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 ...
Stéphane Chazelas's user avatar
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, ...
Marcus Müller's user avatar
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 ...
Ed Morton's user avatar
  • 27.9k

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