#!/bin/bash
if [ -f "$1" ] #parameter is file name, if i exists...
then
VARIABLE=`cat "$1"` #assign what's inside into VARIABLE
fi
I've tried bash -x script_01.sh "file"
and the tracing works:
+ '[' -f file ']'
++ cat file
+ VARIABLE='Wednesday, November 4, 2015 04:45:47 PM CET'
But the problem is that when I echo $VARIABLE, it's empty. Do you guys have any tips on how to make it work? Thank you.
VARIABLE
is set in the process that runs the script, not the process which called the script. If you want to set it in your current environment, you need to source the file instead.
. script_01.sh "file"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.