Hello MDL Todays question is: How do I move specific files inside a folder to dev null? Say I gave file things.log, things2.log and so on and I have things.txt, things2.txt and so on, is there a command to move all *.logs files and not delete the *.txt ones?? Im too lazy to look for the answer myself and I dont know what to search for. Best, Bjørn
rm <pathtofolder>/*.logs . I usually like to do, ls <pathtofolder>/*.logs , to list what would be deleted first just to be sure I'm not deleting the wrong files.
Well this would solve it if I was to remove the files, but I need to do it with "live" files. I need it so they are gone, but still there. They are active log files.
I'd say my understand is very limited, but /dev/null is a pseudo-device that acts as an input and output stream of null. What you're trying to do doesn't make any sense. You can pipe log output to /dev/null and all of the output will be discarded. You can use dd to write /dev/null to the files you want to null and the contents will disappear. You could use rm to remove the files, or shred to overwrite their data on the disk. But you are not going to get very far in linux if you're just expecting to be spoonfed answers and are, by your own admission, unwilling to solve problems and expand your understanding by yourself.
What Im trying to do is, I run a program that creates .log files in a set folder each time it runs. The files have different filenames each time. I want them to be "deleted" in the term that they do not contain data but they are still there. If I just do RM then the file will be gone and the program will crash. I want them to be there, but not grow in size... Also @John, the ending was... For fun.
@bjorn: You want to set the file length to zero bytes, but you want the actual file to stay around. Do you have the source code to this program? Maybe there's a way to turn off log file generation for that specific program. Just a late night thought...
If the program doesn't have a way to disable it's logging, remove each log file, then create a symbolic link from the old path of the logfile to /dev/null.
I thought about that, it will not work because the program makes a new log file almost every time it runs, with a random name.
Thanks for suggestion. Looked into that, but I found an easier way. Seems like I havent read the documentation well enough for the program. Code: forever start -a -l /dev/null script.js will do what I want. Also it has no problems assigning multiple files to it. Silly me. Thanks folks.
That's the great thing about open source. If it's documented poorly, you can always look at the source code and see how it works.