File Download from Sharepoint folder

Hi All,

Please let me know the simple script to download the latest .xlsx file from the share point folder.

I am using the CURL command and which is working fine if give the particular file name. But I have the list of files with the timestamp.'

Ex :

Filename_07202017.xlsx
Filename_07102017.xlsx

I should pick only the latest one which is Filename_07202017.

Thank you.

NAME=$(sort -r < list | head -n 1)

Since the year comes after the month and day in the timestamps in these filenames, the sort needs to be a little more complicated (and assuming that the filename prefix does not contains any other _ s):

NAME=$(sort -r -t_ -k2.4,2.8 -k2.1,2.4 list | head -n 1)

assuming that there is only one filename before the underscore in your list. If there are multiple filename prefixes in your list, you'll need a loop something like:

last=
sort -t_ -k1,1 -k2.4,2.8r -k2.1,2.4r list | while IFS=_ read -r filename time
do	if [ "$last" = "$filename" ]
	then	continue
	fi
	curl other_parameters "$filename"_"$time"
	last="$filename"
done

Note that both of these (and the code suggested by Corona688) assume that list is the name of a file containing one line for each .xlsx file in your share point directory and that that line contains only that file's complete filename.

Thanks for the details . But when try with this it is giving error
" sort: Cannot open list"

Please help me with this issue.

Replace "list" with the name of the file containing

that you have.