Sample Header Ad - 728x90

Group results using comm

0 votes
1 answer
58 views
Using comm I get results that look weird from this: comm -3 <(. "$first_env_file"; env) <(. "$second_env_file"; env) I get something like:
AUTH_LP_ACCOUNT_ID=xxx1
        AUTH_LP_ACCOUNT_ID=xxx2
        AWS_IMAGE_DOMAIN_NAME=abc
AWS_IMAGE_DOMAIN_NAME=zyx
NODE_ENV=local
        NODE_ENV=staging
        NODE_PORT=3000
NODE_PORT=4000
REDIS_HOST=localhost
        REDIS_HOST=redis
(and yes the spaces in front (prepended tabs/spaces) are there) what I would rather it look like is something like this: --begin-- AUTH_LP_ACCOUNT_ID=xx1 AUTH_LP_ACCOUNT_ID=xx2 --------- AWS_IMAGE_DOMAIN_NAME=abc AWS_IMAGE_DOMAIN_NAME=zyx --------- NODE_ENV=local NODE_ENV=staging --------- NODE_PORT=3000 NODE_PORT=4000 --------- REDIS_HOST=localhost REDIS_HOST=redis ---end--- is there a way to accomplish this? 1. to remove prepended lines we can pipe through `sed 's/^ *//. 2. putting --begin-- and ---end--- at begin/end is easy matter 3. but how to group results easily? My only guess at 3 is to loop over each line (skipping first) and if the next result has a different xxx= vs abc= then print a -------- but I am not in love with that.
Asked by Alexander Mills (10744 rep)
Oct 5, 2023, 04:09 PM
Last activity: Oct 5, 2023, 04:33 PM