File: files

package info (click to toggle)
epic 3.004-17.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,192 kB
  • ctags: 3,197
  • sloc: ansic: 40,843; makefile: 530; sh: 129; perl: 17
file content (38 lines) | stat: -rw-r--r-- 768 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
30
31
32
33
34
35
36
37
38
/*
 * FILES script -- complements the new file functions.
 * Written by Jeremy Nelson -- EPIC project
 *
 * These aliases are not anywhere near as fast as /exec'ing the
 * c programs, but they are here to illustrate the usage of the fns.
 */

/* dump a file out to the screen w/o using /exec */
alias cat {
	@ fd = open($0 R)
	while (!eof($fd)) { echo $read($fd) }
	@ close($fd)
}

/* Search for a string in a group of files */
/* This is, of course, case insensitive */
alias grep {
	fe ($1-) x 
	{
		@ fd = open($x R)
		while (!eof($fd)) 
		{ 
			@ line = read($fd)
			if (match(*$0* $line))
				{echo $x: $line}
		}
		@close($fd)
	}
}

/* Write a line to a file w/o using the logging features */
alias log_it {
	@ fd = open($0 W)
	@ write($fd $1-)
	@ close($fd)
}