Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Copy files while showing progress

+5
−0

The standard cp tool from GNU coreutils just copies files silently. This can be a little unnerving when copying large chunks of data. You're left to wonder whether it's actually doing something or just got stuck.

How to copy files and directories in terminal while displaying some kind of progress information?

History

2 comment threads

"The standard cp tool from GNU coreutils just copies files silently." Well, they are designed to d... (2 comments)
You could use rsync instead of cp. Or try https://linux.die.net/man/1/progress (3 comments)

5 answers

+5
−0

Use rsync instead:

$ rsync --progress filename /target/
filename
  1,042,841,600  17%  330.84MB/s    0:00:14
History

0 comment threads

+4
−0

If you don't mind installing an additional tool, progress will do exactly what you want.

progress aims to detect any running command performing significant file I/O. Commonly supported commands include: cp, mv, dd, tar, gzip, gunzip, cat (when copying), rsync (local operations), dpkg, rpm, and various archivers like zip, unzip, xz, bzip2, bunzip2. Its effectiveness depends on how the command performs its I/O and if it keeps file descriptors open predictably.

Example:

$ cp filename /target/ | progress -m
[286427] cp filename
        13.2% (753.5 MiB / 5.6 GiB) 166.1 MiB/s remaining 0:00:29

Note: This will only show the individual progress per file copied, no overall progress if multiple files are copied.

History

1 comment thread

Relation to Pipe Viewer (1 comment)
+2
−0

Pipe Viewer or pv is a program for displaying the throughput of any pipe. It can be used to monitor all sorts of transfers, but for a simple copy you don't even need to pipe any other commands. Just select the file as the input and direct to your destination:

$ pv source.file --output destination.file
2,53MiB 0:00:00 [ 536MiB/s] [=======================================>] 100%
History

0 comment threads

+2
−0

Why not simply use ls -l on the target file? Or ls -lt | head on the directory?

The -lt option makes ls to show long description, including size and timestamp, while sorting by timestamp.

So you can see, from the timestamp, if the command has done recent changes, and from the size, what is the progress.

Maybe you have to send the cp command to the background (preferably by adding an "&" at the end of it, or to open another shell.

If something looks strange, you can uses top or ps aguwx | grep <yourfilename> to see if the process is still actve.

History

0 comment threads

+2
−1

As long as you are working interactively, Midnight Commander is installed by default on every distribution that I know of. It shows elaborate details about the progress of copy and move operations.

History

1 comment thread

Disputation Of The Premise (3 comments)

Sign up to answer this question »