/srv/irclogs.ubuntu.com/2019/12/29/#ubuntu-server.txt

=== JanC_ is now known as JanC
SkyriderQuick question if anyone is around. I'm trying to create a simple  sh script file to remove files in a certain directory on a weekly basis. While it removes the file(s) just fine, it also leave an error output in the console when I run it manually:  --> rm: cannot remove 'directory/*': No such file or directory11:25
SkyriderWith using a simple script line --> rm /directory/*11:26
SkyriderGuess I can use -f to ignore it.11:29
SkyriderCan someone point me to the right direction how to create a mv script if the file does not exist?12:04
SkyriderI tried using "if [ ! -f directory/file ]; then mv directory/file fi" but that doesn't appear to work either. Still same file does not exist error.12:05
weedmichow would you move a file that is not there?  can you explain it a different way and by "script" do you mean a "bash script"?12:24
weedmicSkyrider: ^12:25
Skyrider.sh shell script, and would only like to move the file if it exists.12:26
weedmicok, so IF it exists, then move.12:35
weedmicI saw this one (I think is best)... [ ! -f src ] || mv src dest12:37
SkyriderThink I tried that as well before I used if [ ! -f directory/file ]; then mv12:47
Skyridermoment ^^12:47
SkyriderInteresting, that worked. Wonder why the if statement didn't.12:50
weedmicodd, i did this verbatim and it worked - [ ! -f del.src ] || mv del.src Documents/12:51
weedmicmaybe you did not understnad, this will not crash a script if the document is not found and will continue, but it will not "try" to move a non-existing document12:51
weedmici mean it will appear to work whether the doc is there or not, but not throw an exception if no document is there - it will just go to the next line (doing nothing after theh pipe)12:52
SkyriderIt did work for me as well, but I also found the IF [ -f src ]; then FI statement online, which didn't ^^.12:53
SkyriderMaking sure it doesn't throw out errors, as systemd timers loves to pop up errors if something fails.12:53
weedmic:D - must be why I did not like it (nor recommend it) - i tested the one I liked before showing you12:53
weedmicto me it is odd, b/c I love/need/hopefor errors - w/o them I can't fix things.12:54
Skyrider^_^ appreciate it btw, thanks :D12:58
=== nolan__ is now known as nolan_

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!