Call the function split_filenames with the first argument as the full filename with path. Alternately, set the variable fullfile to this value.
# echo "Called with Arg: $1"
if [ ! "$1" = "" ]
# echo I got this filename for processing $fullfile
echo "filename $filename"
if [ "$pathonly" = "$fullfile" ]
echo "Path $pathonly"
echo "Name $nameonly"
chkper=$(echo $fullfile | grep -c "\.")
# echo "Number of periods:$chkper"
if [ ! "$chkper" = "0" ]
echo "Extension $ext"
echo "No extension"
for i in ~/Dropbox/SSH\ Keys/*
echo Path and Name: $i
#cp "$i" testssh/
In the example, the main event calls the function from a loop which cycles through all the files in the specified directory.
Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.