This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to count files/folders on NCBI ftp server?

Hi,

I log in NCBI ftp server by this way:

ftp ftp.ncbi.nih.gov

And then cd to ./genomes/refseq/.I want to check how many folders/genomes are in the refeq folder, what command should I use?

I used this way to do it:

ls . list # save to local file 'list', then use wc -l to count

do you have easier way?

Thanks, Tao

ftp ncbi linux shell

2 answers

I would use a little script to handle this type of work. For example,

or the equivalent:

You can modify those to get what you need from the list.

That's great! I like the python version! thanks so much!

Glad I could help. You might want to add some debugging to the python because I don't think those commands will warn if they fail. There is a lot of test statements in the perl to be safe and the python should probably also have some tests.

That's very good suggestion, thanks!

you could probably just pipe instead of saving to a local file. i.e. ls -l | wc -l

disclosure: haven't checked it for bugs or reliability

ftp> ls | wc -l usage: ls remote-directory local-file

pipe command doesn't work on ftp mode

Ah yea I checked it on my local directory. Looks like the script would do the job for you anyways!

Log in to answer this question.