Skip to main content

Questions tagged [command-substitution]

Command substitution is the replacement of a command with the result returned after it is evaluated.

command-substitution
0 votes
1 answer
31 views

Bash command substitution issues

I'm writing a Python script to parse various logs across different hosts. I can successfully run bash scripts via Python's subprocess module, however, I want to minimize the number of ssh calls, so I'...
OM222O's user avatar
  • 980
0 votes
1 answer
87 views

Bash dialog: chained command substitution if problem

I want to write a script based on dialog programbox (or others) and capture a command's stderr and the stdout passed to dialog into an array (if any), as well as the command's exit status (as last ...
fozzybear's user avatar
  • 117
0 votes
1 answer
82 views

Sed's append command (a) is for some reason deleting all file's text and then appending the provided text

I'm trying with GNU sed command to append a line into a file inside a block/section, specifically just a line under the start of the block/section. As a result it empties the file (maybe leaves a ...
d3vr10's user avatar
  • 21
-1 votes
1 answer
50 views

I am having trouble using the date function along with the vim command in bash

I have recently started journaling and I wanted to create a program to make the process a little easier. The program uses bash to mount an external hard drive (with a known name) and open the journal ...
UnoriginalName369636's user avatar
0 votes
1 answer
33 views

A crontab fails to run a task with a date command

In a project, I am trying to run a command that processes data from the day before (a rather common use case). I am running it from a Docker container (python:3.11 derived) and therefore a Linux ...
Corentor's user avatar
  • 689
2 votes
1 answer
94 views

Fail bash script when command expansion fails

I'd like to be able to warn and fail if the following command expansion fails: #!/usr/bin/env bash set -Eeuo pipefail echo "$(invalid_cmd)" echo "$?" Instead of failing, I get ...
kporter's user avatar
  • 2,748
0 votes
1 answer
111 views

Expansion in an eval variable

Is it possible to do expansion inside an eval variable? Example: $ eval VAR=`echo some/path/{file1,file2}` bash: some/path/file2: No such file or directory I expected the same result as without using ...
myself600's user avatar
-1 votes
1 answer
288 views

Openssl return values in bash scripts

Openssl 3.0.2.15 on Ubuntu Server (current) So, my forensics class was working on a problems I used for bash and we found a kind of strange thing. If you are trying to detect a valid password using a ...
dwhite's user avatar
  • 5
1 vote
2 answers
147 views

Order of Command substitution and Arithmetic expansion in bash

The book “Learning the bash Shell” 3rd ed. by Cameron Newham and Bill Rosenblatt has at page 181 a picture describing the command-line processing of bash shell. That picture shows that Command ...
diciotto's user avatar
1 vote
1 answer
61 views

assign output of a cat | sed | awk to an array

Updated Question with code. I have written a script that retrieves files from a remote server via scp. Then I want the script to delete the success file that has been retrieved. But instead of ...
goced's user avatar
  • 61
0 votes
1 answer
55 views

How can I nest $(var) variable command substitutions?

I have a need to update a bash/perl script to create a file with a system process (mktemp), I need to set the filename for creation, and for this I want to use the current system date: LOGFILE=$(/bin/...
Martin's user avatar
  • 22.7k
0 votes
0 answers
44 views

Bash script regex on parameter [duplicate]

I have a script like this: #!/bin/bash ...
vaso123's user avatar
  • 12.4k
0 votes
2 answers
2k views

Kubernetes CronJob - Escaping a cURL command with nested JSON and command substitution

I have the following Kubernets CronJob definition: apiVersion: batch/v1 kind: CronJob metadata: name: myCronJob spec: schedule: "*/1 * * * *" failedJobsHistoryLimit: 1 ...
leifericf's user avatar
  • 2,362
0 votes
0 answers
60 views

BASH: Variables in a function piped to dialog are lost

I have a script with a function which does some stuff and sets some variables to be used later in the script. This function is also echoing progress (echo 10, echo 20 etc.) and is piped to a "...
Occam's Chainsaw's user avatar
1 vote
1 answer
46 views

how do I get rid of the single quotes around my string

I have a zsh script. There is a function ... imgPrep() { local inFilePath=$1 local outFilePath=$2 local cropHeight=$3 local resize=$4 shift; shift; shift; shift local options=$@ convert ${inFilePath} ...
timelessbeing's user avatar

15 30 50 per page
1
2 3 4 5
16