Skip to main content
Fix quoting
Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

I would use a temporary file to store the complex function result, and then read the value from the temp file for processing.

# Create a temp file for storage
tmppath=$(mktemp)
# run the command and get the output to the temp file
complex_command > ${tmppath}
# read the file into variable
message=$(cat "${tmppath}")
# use the variable
echo "$message"

rm -f ${tmppath}

# Create a temp file for storage
tmppath=$(mktemp)
# run the command and get the output to the temp file
complex_command > "${tmppath}"
# read the file into variable
message=$(cat "${tmppath}")
# use the variable
echo "$message"

rm -f "${tmppath}"

The usage of mktemp can refer to How create a temporary file in shell script?

I would use a temporary file to store the complex function result, and then read the value from the temp file for processing.

# Create a temp file for storage
tmppath=$(mktemp)
# run the command and get the output to the temp file
complex_command > ${tmppath}
# read the file into variable
message=$(cat "${tmppath}")
# use the variable
echo "$message"

rm -f ${tmppath}

The usage of mktemp can refer to How create a temporary file in shell script?

I would use a temporary file to store the complex function result, and then read the value from the temp file for processing.

# Create a temp file for storage
tmppath=$(mktemp)
# run the command and get the output to the temp file
complex_command > "${tmppath}"
# read the file into variable
message=$(cat "${tmppath}")
# use the variable
echo "$message"

rm -f "${tmppath}"

The usage of mktemp can refer to How create a temporary file in shell script?

deleted 51 characters in body
Source Link
Chris Davies
  • 128.4k
  • 16
  • 179
  • 324

I would use a temporary file to store the complex function result, and then read the value from the temp file for processing.

# Create a temp file for storage
tmppath=$(mktemp)
# run the command and get the output to the temp file
complex_command > ${tmppath}
# read the file into variable
message=$(cat "${tmppath}")
# use the variable
echo "$message"

rm -f ${tmppath}

The usage of mktemp can refer to How create a temporary file in shell script?

Edit: fix typo according to comments from @roaima

I would use a temporary file to store the complex function result, and then read the value from the temp file for processing.

# Create a temp file for storage
tmppath=$(mktemp)
# run the command and get the output to the temp file
complex_command > ${tmppath}
# read the file into variable
message=$(cat "${tmppath}")
# use the variable
echo "$message"

rm -f ${tmppath}

The usage of mktemp can refer to How create a temporary file in shell script?

Edit: fix typo according to comments from @roaima

I would use a temporary file to store the complex function result, and then read the value from the temp file for processing.

# Create a temp file for storage
tmppath=$(mktemp)
# run the command and get the output to the temp file
complex_command > ${tmppath}
# read the file into variable
message=$(cat "${tmppath}")
# use the variable
echo "$message"

rm -f ${tmppath}

The usage of mktemp can refer to How create a temporary file in shell script?

fix typo
Source Link

I would use a temporary file to store the complex function result, and then read the value from the temp file for processing.

# Create a temp file for storage
tmppath=$(mktemp)
# run the command and get the output to the temp file
complex_command > ${tmppath}
# read the file into variable
message=$(echocat $"${tmppath}")
# use the variable
echo $message"$message"

rm -f ${tmppath}

The usage of mktemp can refer to How create a temporary file in shell script?

Edit: fix typo according to comments from @roaima

I would use a temporary file to store the complex function result, and then read the value from the temp file for processing.

# Create a temp file for storage
tmppath=$(mktemp)
# run the command and get the output to the temp file
complex_command > ${tmppath}
# read the file into variable
message=$(echo ${tmppath})
# use the variable
echo $message

rm -f ${tmppath}

The usage of mktemp can refer to How create a temporary file in shell script?

I would use a temporary file to store the complex function result, and then read the value from the temp file for processing.

# Create a temp file for storage
tmppath=$(mktemp)
# run the command and get the output to the temp file
complex_command > ${tmppath}
# read the file into variable
message=$(cat "${tmppath}")
# use the variable
echo "$message"

rm -f ${tmppath}

The usage of mktemp can refer to How create a temporary file in shell script?

Edit: fix typo according to comments from @roaima

Source Link
Loading