copy /proc folder
Other day, I was trying to copy the proc folder with following command:
tar cvzf /tmp/proc.tgz /proc
and I found out that all the files in tar were empty. Strange it may seem but lot of people are facing this as /proc is not a regular filesystem, so I wrote a quick script to copy the proc folder. Here is the script:
cd / mkdir /tmp/proc [[ -z $1 ]] && exit -1 find /proc/$1/ -not -name pagemap | while read F ; do D=/tmp/$F if [[ -d $F ]] then echo "$(ls -ld $F) => Directory" mkdir -p $D fi if [[ -L $F ]] then echo "$(ls -ld $F) => copied" cp -P $F /tmp/$F elif [[ -f $F ]] then echo "$(ls -ld $F) => Cat" cat $F > /tmp/$F else echo "Dont know $F" fi done
Related Articles:
- 2018/11/19 xev – Check the X keyboard events
- 2018/11/12 Get to your ebooks quickly
- 2014/05/05 Some nice linux tutorials
- 2010/05/24 Inotify Example - Introduction to Inotify with a C Program Example
- 2019/03/11 cool sed/grep magic to convert output to csv format
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.