linux command to get size of files and directories present in a particular folder?

Use ls command for files and du command for directories. Checking File Sizes ls command will not list the actual size of directories(why?). Therefore, we use du for this purpose. Checking Directory sizes Including -h option in any of the above commands (for Ex: ls -lh * or du -sh) will give you size in human readable format (kb, mb,gb, …) For more information see man ls and man du

How to copy files?

shutil has many methods you can use. One of which is: Copy the contents of the file named src to a file named dst. Both src and dst need to be the entire filename of the files, including path. The destination location must be writable; otherwise, an IOError exception will be raised. If dst already exists, it will be replaced. Special files such as character or block … Read more

What does it mean to mount a file system in linux?

A better way to describe “mount” is “attach”. The filesystem being mounted is attached to an empty directory of the existing filesystem. That is, the top level directory of the mounted filesystem becomes the directory on the existing filesystem. Subdirectories of the mounted filesystem become the subdirectories of the former directory on the existing filesystem, … Read more

Printing the last column of a line in a file

You don’t see anything, because of buffering. The output is shown, when there are enough lines or end of file is reached. tail -f means wait for more input, but there are no more lines in file and so the pipe to grep is never closed. If you omit -f from tail the output is shown immediately: @EdMorton is right of course. Awk can search for A1 as well, … Read more

Fastest way to check if a file exist using standard C++/C++11,14,17/C?

Well I threw together a test program that ran each of these methods 100,000 times, half on files that existed and half on files that didn’t. Results for total time to run the 100,000 calls averaged over 5 runs, Method Time exists_test0 (ifstream) 0.485s exists_test1 (FILE fopen) 0.302s exists_test2 (posix access()) 0.202s exists_test3 (posix stat()) 0.134s The stat() function provided the … Read more