The basics of copying files and whole directories on Linux.
Copying files on a Linux OS can be done with cp this is obviously short for “copy”.
The syntax for cp is the source first and destination second
[source] [destination]
Copying just one file into a directory:
cp image.jpg /data/photos/
Copying two or more files into a directory:
cp image.jpg another.jpg /data/photos/
Use -p to keep file permissions and timestamps on the copied files
cp -p image.jpg /data/photos/
With cp the flag -r means recursive, to copy a whole directory into another:
cp -r /data/photos /backups/photos
This will copy the contents of the /data/photos folder into /backups/photos
To not overwrite the file if it exists use -n which is no clobber:
cp -r -n /data/photos /backups/photos
Getting a visual output from the cp task is done with the -v flag
cp -v image.jpg /data/photos/
Will output
'image.jpg' -> '/data/photos/image.jpg'
A drained and empty Kennington reservoir images from a drone in early July 2024. The…
Merrimu Reservoir from drone. Click images to view larger.
Using FTP and PHP to get an array of file details such as size and…
Creating and using Laravel form requests to create cleaner code, separation and reusability for your…
Improving the default Laravel login and register views in such a simple manner but making…
Laravel validation for checking if a field value exists in the database. The validation rule…