BASH Lesson 5 while loops
Uploader Comments (metalx1000)
Top Comments
-
@theif519: Sure, I'll make a video right now going over the while command a little more. Is there anything in particular you want to know?
All Comments (45)
-
man i remembere I was able to take screenshots every few seconds with something close to this
"while [ 1 ];do import -window root 101{1..10}.jpg;sleep 5s;done"
but back then those 10 screenshot wouldn't be overwritten and at the 10th picture the while loop would stop. Do you have any idea.
-
@tsumulunch5 it's an error in video encoding :/ it says let x=1;
-
@metalx1000 a tutorial about arguments would be good to , please
-
@theif519: I think you mean "$#" and I think it would be more like "while [ $# -lg 3 ]" or something like that depending on the situation. But, that's getting more into arguments, not while loops. But, I will be uploading a new while loop video in a bit.
Thank you for the wonderful tutorials. You rock!
giannis321giannis321 6 months ago 5
@giannis321giannis321: Nope problem, you are welcome.
metalx1000 6 months ago
Combined with some image manipulation concepts from some of your other tutorials, this can be used as a very neat tool to clean up naughty images from one's hdd without risking unauthorized recovery of said files by nosy persons:
ls|while read pic;do convert -modulate 0 "$pic" "$pic";done
This will overwrite any jpg in the directory from which it is run with black pixels. However, you could just as easily perform any action you wish... Use your imagination!
cmommsen1 8 months ago
@cmommsen1: I like that you are being creative and using the things you learn and know to come up with solutions to problems. I only see one problem. Just because you are replacing a file with the converted file doesn't mean that the new file is being written to the same place on the hard drive. So, file recovery would still be possible in some cases.
But, still, I like that you are thinking and using your imagination. That is a needed thing to become a good programer.
metalx1000 8 months ago
@metalx1000 Yeah that's a good point, especially on a complex storage configuration like RAID or SSD systems where the drive's I/O chips are performing complex caching operations.
So what would say would be a good way to edit an file in a way that modifies the actual 1's and 0's of that file in real time? I know there are many programs for permanently erasing files, but it seems like all it should really take is a simple script or single command.
cmommsen1 8 months ago
@cmommsen1: Well, to over write and entire drive or partition you could do something like this:
dd if=/dev/zero of=/dev/hda
As far as over writing certain places on a drive, I don't know. Never tried that. I'm sure there is a way. I mean besides rapidly writing and deleting files to a drive, which would not be good for the drive for a few reasons and still wouldn't grantee you got the spots you wanted.
metalx1000 8 months ago