Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting files using AWK 2

Status
Not open for further replies.

micky123

MIS
Mar 11, 2004
3
US
I have a couple of GNU AWK scripts that are used on multiple platforms (LINUX, WINDOWS and BSD). The scripts generate a few intermediate files that are not needed finally. Is there a way in AWK to delete them at the end?

Thanks,

-M
 
Take a look at the system builtin function, like this:
END{system("rm -f "tmpfile)}

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
I am guessing this would not be platform independent. Ideally I would like something that would work for both windows and unix without any modification.
 
In your Windows environment, either install some unix-like utilities (cygwin, interix, mks, ...) or write a RM.BAT script.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
If you are using GNU Awk (gawk) or mawk, you can read the environmental variables.
Code:
BEGIN { if ( ENVIRON["HOME"] ~ "^/" )
    deletecommand = "rm "
  else
    deletecommand = "del "
  print deletecommand
#   system( deletecommand "junk" )
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top