I have two function first one call usage -file
to get the file from the user. It has long filename, so this function strips just what I need.
For example:
./test.sh -file some_example_list_data2017.csv
It give me data2017
(which is what I want).
function get_file_name() {
filename=$1
if [ -f $filename ]
then
echo "${filename}" | awk (make long filename short)
else
echo "${filename} not found"
fi
}
Second function: I want to pass the above $filename
here, since it already has full filename. And I want to display only some content on the screen. But this time using
./test.sh -display someexample_list_data2017.csv
function parse_above_file() {
// here I want get_file_name and display the content
filename=$1
echo ${filename} | awk/sed/egrep (do something and display)
}
But second function isn't getting the filename passed. When it ran the script it just prints nothing.