Skip to main content
9 votes

Iterating over the contents of a file

From help while: Execute commands as long as a test succeeds. From help read: Read a line from the standard input and split it into fields. and: Exit Status: The return code is zero, unless end-...
kos's user avatar
  • 3,487
4 votes

output of a command framed by a couple of '#' characters

If you want to make the lines the same length, the tricky part is printing a correct amount of # signs dynamically. You could do something like this (in Bash or zsh): #!/bin/bash fill() { local ...
ilkkachu's user avatar
  • 141k
4 votes

Iterating over the contents of a file

You haven't exactly asked any question here but I'll take a stab at answering you. cat file.txt | .. will obviously send the contents of file.txt to the pipeline to read. read by default will read ...
jesse_b's user avatar
  • 37.6k
2 votes

output of a command framed by a couple of '#' characters

You could also use a tool for ASCII-art, e.g. install boxes. For details see also the long answer in related question. Adapted the example: psql -qAtc "SELECT version()" | awk {'print $1, $2'...
hc_dev's user avatar
  • 151
2 votes
Accepted

Why doesn't 'export' give the export attribute while 'set -a' does?

It's the one and same export attribute, just the help texts there aren't too consistent with each other. The export attribute is how the shell marks variables for (automatic) export. export gives the ...
ilkkachu's user avatar
  • 141k
1 vote

output of a command framed by a couple of '#' characters

Some things aren't actually worth writing code for, and this is one of those cases. I would expect the version of PostGreSQL to change infrequently, so it shouldn't need to be calculated every time ...
Martin Kealey's user avatar
1 vote

Bash script to start java spring boot application from SSH

However, any command executed by ssh cannot be executed in the background permanently But you can do this via service/systemctl [Unit] Description=xxxx After=network.target syslog.target [Service] ...
NotoChen's user avatar
1 vote
Accepted

output of a command framed by a couple of '#' characters

You should be able to output the result of that command using a combination of $() and quote marks like so- echo "### $(psql -qAtc "SELECT version()" | awk {'print $1, $2'}) ############...
kestrel's user avatar
  • 64
1 vote

Delete 2-line paragraphs, keep 3-line paragraphs, maintain newline between all

With GNU awk: awk 'BEGIN{FS=RS; RS=""} NF==3{print; print ""}' file Output: aaa aaaaaa bb bbb cc cccc ccccc cccc fff ff ggg gggg gggg hhh hhh hh hhhh Output contains one ...
Cyrus's user avatar
  • 12.4k
1 vote
Accepted

How to make ssh return immediately after running background job

According to the ssh man page The session terminates when the command or shell on the remote machine exits and all X11 and TCP connections have been closed. The reason ssh doesn't exit right away is ...
user10489's user avatar
  • 7,449
1 vote

How to make ssh return immediately after running background job

The behavior is the same, actually. What happens is that you are sending the sleep to the background on the remote machine, but you are not sending the ssh command to the background on your local ...
terdon's user avatar
  • 244k

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