I'm a newbie in scripting and I have this problem:
I want to use the fuser
command to check if a file with that name is present. I want to save the output of the command and later use it to rename the file before loading.
I have tried the following:
#!/bin/bash
file_name='test'
echo 'file_name before: '$file_name
file_name=`fuser FILE_DIR/SD/Test_file_??????????????.dat`
echo 'file_name after: '$file_name'
However, the result of the above code is:
-bash-3.00$ script.sh
file_name before :test
FILE_DIR/SD/Test_file_20180823120345.dat
file_name after:
The output of the command is not getting stored in variable but getting displayed in screen and I can't figure out why!
What I want to do is to store Test_file_20180823120345.dat
in the file_name
variable, and then remove the timestamp from that and rename the file to Test_file_20180823.dat
.
Then after loading the data in the staging table again rename the file to the old file name that we have received and then archive the file with its original name.