How to preserve line breaks when storing command output to a variable?

I’m using bash shell on Linux. I have this simple script … #!/bin/bash TEMP=`sed -n “https://stackoverflow.com/””Starting deployment of”‘/,/'”Failed to start context”‘/p’ “/usr/java/jboss/standalone/log/server.log” | tac | awk “https://stackoverflow.com/””Starting deployment of”‘/ {print;exit} 1’ | tac` echo $TEMP However, when I run this script ./temp.sh all the output is printed without the carriage returns/new lines. Not sure if … Read more

Run a string as a command within a Bash script

I have a Bash script that builds a string to run as a command Script: #! /bin/bash matchdir=”/home/joao/robocup/runner_workdir/matches/testmatch/” teamAComm=”`pwd`/a.sh” teamBComm=”`pwd`/b.sh” include=”`pwd`/server_official.conf” serverbin=’/usr/local/bin/rcssserver’ cd $matchdir illcommando=”$serverbin include=”$include” server::team_l_start=”${teamAComm}” server::team_r_start=”${teamBComm}” CSVSaver::save=”true” CSVSaver::filename=”out.csv”” echo “running: $illcommando” # $illcommando > server-output.log 2> server-error.log $illcommando which does not seem to supply the arguments correctly to the $serverbin. Script output: running: … Read more

How to set child process’ environment variable in Makefile

I would like to change this Makefile: SHELL := /bin/bash PATH := node_modules/.bin:$(PATH) boot: @supervisor \ –harmony \ –watch etc,lib \ –extensions js,json \ –no-restart-on error \ lib test: NODE_ENV=test mocha \ –harmony \ –reporter spec \ test clean: @rm -rf node_modules .PHONY: test clean to: SHELL := /bin/bash PATH := node_modules/.bin:$(PATH) boot: @supervisor \ … Read more

How to merge 2 JSON objects from 2 files using jq?

I’m using the jq tools (jq-json-processor) in shell script to parse json. I’ve got 2 json files and want to merge them into one unique file Here the content of files: file1 { “value1”: 200, “timestamp”: 1382461861, “value”: { “aaa”: { “value1”: “v1”, “value2”: “v2” }, “bbb”: { “value1”: “v1”, “value2”: “v2” }, “ccc”: { … Read more