This happened to me while I was downloading mail archives from IETF. lftp client, that I'm using, shows only a file that it is currently downloading, not a directory in which it is, i.e. the output looks something like this:
lftp ftp.ietf.org:/> mirror ietf-mail-archive
`2010-04.mail' at 518040 (50%) 120.1K/s eta:4s [Receiving data]
A solution to search for a given file won't work because this particular filename is in almost every directory.
The solution I used, was the following shell command:
$ ( du -sk *; sleep 5; du -sk * ) | sort | uniq -uThis command has to be executed inside ietf-mail-archive directory. It works as follows:
36204 mmusic
36848 mmusic
- First 'du -sk *' command lists all directory sizes.
 - Then it sleeps for a five seconds (sleep 5) waiting for a directory that is currently changing, to change its size.
 - Again we get all the directory sizes using the second du -sk command.
 - Parentheses around all three are used so all of those commands execute within a subshell and that we receive output of both du commands.
 - Then, we sort output. Note that the directories that don't change will be one after the another, while the one that changes won't be.
 - Finally, we use uniq command to filter out all the duplicate lines, meaning, only the directory that changed will be passed to the output.
 
No comments:
Post a Comment