inital P01 version published - Instructions are available under Moodle
This commit is contained in:
		
							parent
							
								
									a7eda8d4b2
								
							
						
					
					
						commit
						2e878d8489
					
				| 
						 | 
				
			
			@ -0,0 +1,26 @@
 | 
			
		|||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# produces a tabular output of all executables as found over the $PATH environment variable
 | 
			
		||||
# - output format: [1-based index of $PATH entry]:[$PATH entry]:[name of the executable]
 | 
			
		||||
#   - e.g. 6:/bin:bash
 | 
			
		||||
# - the first argument (if given) is used as alternative to $PATH (e.g. for testing purposes)
 | 
			
		||||
# usage: ./get-exec-list-arg.sh            # examines $PATH
 | 
			
		||||
# usage: ./get-exec-list-arg.sh "$PATH"    # equivalent to the above call
 | 
			
		||||
# usage: ./get-exec-list-arg.sh ".:~/bin"  # examines the current directory (.) and ~/bin
 | 
			
		||||
 | 
			
		||||
# argument handling
 | 
			
		||||
path="$1"
 | 
			
		||||
[ -n "$path" ] || path="$PATH"
 | 
			
		||||
 | 
			
		||||
# input-field-separator: tells the shell to split in the 'for' loop the $var by ":"
 | 
			
		||||
IFS=":"
 | 
			
		||||
 | 
			
		||||
for p in $path
 | 
			
		||||
do
 | 
			
		||||
    i=$((i+1))
 | 
			
		||||
    [ -n "$p" ] || p="."
 | 
			
		||||
    if [ -d "$p" ] && [ -x "$p" ]
 | 
			
		||||
    then
 | 
			
		||||
        find -L "$p" -maxdepth 1 -type f -executable -printf "$i:%h:%f\n" 2>/dev/null
 | 
			
		||||
    fi
 | 
			
		||||
done
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,35 @@
 | 
			
		|||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# produces a crude HTML table from a tabular file (given on stdin) with columns separated by ":"
 | 
			
		||||
# usage: tab2html < inbut.txt > output.html
 | 
			
		||||
 | 
			
		||||
awk $* -- '
 | 
			
		||||
BEGIN {
 | 
			
		||||
   FS=":"   # field-separator: which character separats fields in a record (i.e. in a line)
 | 
			
		||||
   print "<!DOCTYPE html>"
 | 
			
		||||
   print "<html>"
 | 
			
		||||
   print "  <head>"
 | 
			
		||||
   print "    <style>"
 | 
			
		||||
   print "      table{border:1px solid black;border-collapse:collapse;}"
 | 
			
		||||
   print "      tr:nth-child(even){background-color: #f2f2f2;}"
 | 
			
		||||
   print "      td{border:1px solid black;padding:15px;}"
 | 
			
		||||
   print "    </style>"
 | 
			
		||||
   print "    <title>Tabular Data</title>"
 | 
			
		||||
   print "  </head>"
 | 
			
		||||
   print "  <body>"
 | 
			
		||||
   print "    <div style=\"overflow-x:auto;\">"
 | 
			
		||||
   print "      <table>"
 | 
			
		||||
}
 | 
			
		||||
{
 | 
			
		||||
   print "        <tr>"
 | 
			
		||||
   for (i = 1; i <= NF; i++) { print "          <td>"$i"</td>" }
 | 
			
		||||
   print "        </tr>"
 | 
			
		||||
}
 | 
			
		||||
END {
 | 
			
		||||
    print "      </table>"
 | 
			
		||||
    print "    </div>"
 | 
			
		||||
    print "  </body>"
 | 
			
		||||
    print "</html>"
 | 
			
		||||
}
 | 
			
		||||
'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,21 @@
 | 
			
		|||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# produces an XML file from a tabular file (given on stdin) with columns separated by ":"
 | 
			
		||||
# usage: tab2xml < inbut.txt > output.xml
 | 
			
		||||
 | 
			
		||||
awk $* -- '
 | 
			
		||||
BEGIN {
 | 
			
		||||
   FS=":"   # field-separator: which character separats fields in a record (i.e. in a line)
 | 
			
		||||
   print "<?xml version=\"1.0\" standalone=\"yes\"?>"
 | 
			
		||||
   print "<Table>"
 | 
			
		||||
}
 | 
			
		||||
{
 | 
			
		||||
   print " <Row>"
 | 
			
		||||
   for (i = 1; i <= NF; i++) { print "  <Col>"$i"</Col>" }
 | 
			
		||||
   print " </Row>"
 | 
			
		||||
}
 | 
			
		||||
END {
 | 
			
		||||
    print "</Table>"
 | 
			
		||||
}
 | 
			
		||||
'
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue