How to count files/folders on NCBI ftp server?
2
0
Entering edit mode
7.9 years ago
Tao ▴ 530

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 • 4.3k views
ADD COMMENT
6
Entering edit mode
7.9 years ago
SES 8.6k

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.

ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

That's very good suggestion, thanks!

ADD REPLY
0
Entering edit mode
7.9 years ago
Spencer D. • 0

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

ADD COMMENT
0
Entering edit mode

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

pipe command doesn't work on ftp mode

ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 2956 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6