Skip to content

Instantly share code, notes, and snippets.

@anil1kuppa
Created April 12, 2023 03:01
Show Gist options
  • Save anil1kuppa/33f6e53146ce08442f704e85b03aa3b2 to your computer and use it in GitHub Desktop.
Save anil1kuppa/33f6e53146ce08442f704e85b03aa3b2 to your computer and use it in GitHub Desktop.
List the number of files in sftp
echo "ls *.csv" | sftp -q <username>@<hostname>:<directory> | grep -v '^stfp>' | wc -l
// E.g. echo "ls *.csv" | sftp -q [email protected]:/nfiIndustries | grep -v '^stfp>' | wc -l
#!/bin/bash
username=
hostname=
currentdir=
filename=
(
echo cd $currentdir
for file in `(sed -n -e '1,2p' $filename)`
do
echo rename $file /nfiIndustries/Historical_candidate_`echo $file|cut -d'_' -f2-`
done
)|sftp $username@$hostname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment