File: demo_tmpfile

package info (click to toggle)
runawk 1.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 712 kB
  • sloc: awk: 1,127; ansic: 736; sh: 420; makefile: 103
file content (29 lines) | stat: -rwxr-xr-x 473 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env runawk

#use "tmpfile.awk"
#use "exitnow.awk"

# This demo generates temporary file names and outputs them to stdout

BEGIN {
	tmpfile1  = tmpfile()
	tmpfile2  = tmpfile()
	tmpsubdir = tmpfile()

	print "file 1" > tmpfile1

	print "file 2" > tmpfile2

	system("mkdir " tmpsubdir)

	tmpfile3 = tmpsubdir "/file3"
	print "file 3" > tmpfile3

	close(tmpfile1)
	close(tmpfile2)
	close(tmpfile3)

	system("cat " tmpfile1 " " tmpfile2 " " tmpfile3)

	exitnow(0)
}