I'm getting the strong feeling that...

L Carver

New Member
Joined
Sep 29, 2018
Messages
4
Reaction score
2
Credits
0
...every script I write/rewrite since installing a newer Kubuntu is written wrong from the start.

The one I'm having trouble with now is
  • supposed to delete text files ending in .log
  • failing to do this one simple thing.
My script:
Code:
#!/bin/bash

echo "This script will remove .log files from the current directory."

   rm -v "*log" 2>/dev/null
#   rm -v "*log" 1>/dev/null

    echo "Done."
exit 0
Returns (in stout):
Code:
This script will remove .log files from the current directory.
Done.
When I check the real results of running it.
Code:
ls *log
killo.log  killtemp.log

So what the expletive is wrong with the script?

Carver
 


G'day Carver :)

I am just a novice scripter, but have you tried it with

Code:
*.log

# instead of

*log
?

Other than that, one of our scripting gurus will be along sooner or later :D

Wizard
 
Hello L Carver,

Remember also, some logs are owned by root, you might have to run your script with root powers.

Take a look at /var/log and list all of the files.

Why not use a logrotate ? Deleting all the logs... its a bit.. hard no?
 
G'day Carver :)

I am just a novice scripter, but have you tried it with

Code:
*.log

# instead of

*log
?

Other than that, one of our scripting gurus will be along sooner or later :D

Wizard
Yeap, Chris I think the same.
 

Members online


Latest posts

Top