Guest User

Untitled

a guest
Jun 23rd, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.26 KB | None | 0 0
  1. Languages
  2. Recursively enumerable
  3. Regular
  4.  
  5. Minimal automaton
  6. Turing machine
  7. Finite
  8.  
  9. Languages Minimal automaton
  10. Recursively enumerable Turing machine
  11. Regular Finite
  12.  
  13. Languages Minimal automaton
  14. Recursively enumerable Turing machine
  15. Regular Finite
  16.  
  17. $ cat 1
  18. Chomsky hierarchy
  19. Type-0
  20.  
  21. $ cat 2
  22. Grammars
  23. Unrestricted
  24.  
  25. $ paste 1 2 | pr -t -e20
  26. Chomsky hierarchy Grammars
  27. Type-0 Unrestricted
  28. — (no common name)
  29.  
  30. paste file1 file2 | column -s $'t' -t
  31.  
  32. $ paste <(echo foo; echo; echo barbarbar) <(seq 3) | column -s $'t' -t
  33. foo 1
  34. 2
  35. barbarbar 3
  36.  
  37. $ paste <(echo foo; echo; echo barbarbar) <(seq 3) | column -s $'t' -tn
  38. foo 1
  39. 2
  40. barbarbar 3
  41.  
  42. paste file1 file2 | pr -t -e24
  43.  
  44. ┌──────────────────────┬────────────────┬──────────┬────────────────────────────┐
  45. │ Languages │ Minimal │ Chomsky │ Unrestricted │
  46. ├──────────────────────┼────────────────┼──────────┼────────────────────────────┤
  47. │ Recursive │ Turing machine │ Finite │ space indented │
  48. ├──────────────────────┼────────────────┼──────────┼────────────────────────────┤
  49. │ Regular │ Grammars │ │ ➀ unicode may render oddly │
  50. ├──────────────────────┼────────────────┼──────────┼────────────────────────────┤
  51. │ 1 2 3 4 spaces │ │ Symbol-& │ but the column count is ok │
  52. ├──────────────────────┼────────────────┼──────────┼────────────────────────────┤
  53. │ │ │ │ Context │
  54. └──────────────────────┴────────────────┴──────────┴────────────────────────────┘
  55.  
  56. #!/bin/bash
  57. { echo -e "<html>n<table border=1 cellpadding=0 cellspacing=0>"
  58. paste "$@" |sed -re 's#(.*)#x091x09#' -e 's#x09# </pre></td>n<td><pre> #g' -e 's#^ </pre></td>#<tr>#' -e 's#n<td><pre> $#n</tr>#'
  59. echo -e "</table>n</html>"
  60. } |w3m -dump -T 'text/html'
  61.  
  62. +------------------------+-------------------+-------------------+--------------+
  63. | Languages | Minimal automaton | Chomsky hierarchy | Grammars |
  64. | Recursively enumerable | Turing machine | Type-0 | Unrestricted |
  65. | Regular | Finite | — | |
  66. | Alphabet | | Symbol | |
  67. | | | | Context |
  68. +------------------------+-------------------+-------------------+--------------+
  69.  
  70. #!/bin/bash
  71.  
  72. # Note: The next line is for testing purposes only!
  73. set F1 F2 F3 F4 # Simulate commandline filename args $1 $2 etc...
  74.  
  75. p=' ' # The pad character
  76. # Get line and column stats
  77. cc=${#@}; lmax= # Count of columns (== input files)
  78. for c in $(seq 1 $cc) ;do # Filenames from the commandline
  79. F[$c]="${!c}"
  80. wc=($(wc -l -L <${F[$c]})) # File length and width of longest line
  81. l[$c]=${wc[0]} # File length (per file)
  82. L[$c]=${wc[1]} # Longest line (per file)
  83. ((lmax<${l[$c]})) && lmax=${l[$c]} # Length of longest file
  84. done
  85. # Determine line-count deficits of shorter files
  86. for c in $(seq 1 $cc) ;do
  87. ((${l[$c]}<lmax)) && D[$c]=$((lmax-${l[$c]})) || D[$c]=0
  88. done
  89. # Build 'n' strings to cater for short-file deficits
  90. for c in $(seq 1 $cc) ;do
  91. for n in $(seq 1 ${D[$c]}) ;do
  92. N[$c]=${N[$c]}$'n'
  93. done
  94. done
  95. # Build the command to suit the number of input files
  96. source=$(mktemp)
  97. >"$source" echo 'paste '
  98. for c in $(seq 1 $cc) ;do
  99. ((${L[$c]}==0)) && e="x" || e=":a -e "s/^.{0,$((${L[$c]}-1))}$/&$p/;ta""
  100. >>"$source" echo '<(sed -re '"$e"' <(cat "${F['$c']}"; echo -n "${N['$c']}")) '
  101. done
  102. # include the ASCII-art Table framework
  103. >>"$source" echo ' | sed -e "s/.*/| & |/" -e "s/t/ | /g" ' # Add vertical frame lines
  104. >>"$source" echo ' | sed -re "1 {h;s/[^|]/-/g;s/|/+/g;p;g}" ' # Add top and botom frame lines
  105. >>"$source" echo ' -e "$ {p;s/[^|]/-/g;s/|/+/g}"'
  106. >>"$source" echo
  107. # Run the code
  108. source "$source"
  109. rm "$source"
  110. exit
  111.  
  112. paste <(sed -re :a -e 's/^.{1,'"$(($(wc -L <F1)-1))"'}$/&./;ta' F1) F2
  113.  
  114. # output (No trailing whitespace)
  115. Languages............. Minimal automaton
  116. Recursively enumerable Turing machine
  117. Regular............... Finite
  118.  
  119. paste <( sed -re :a -e 's/^.{1,'"$(($(wc -L <F1)-1))"'}$/&./;ta' F1 )
  120. <( sed -re :a -e 's/^.{1,'"$(($(wc -L <F2)-1))"'}$/&./;ta' F2 )
  121.  
  122. # output (With trailing whitespace)
  123. Languages............. Minimal automaton
  124. Recursively enumerable Turing machine...
  125. Regular............... Finite...........
  126.  
  127. paste left.txt right.txt | expand -t $(($(wc -L <left.txt) + 1))
  128. paste left.txt right.txt | expand -t $(awk 'n<length {n=length} END {print n+1}')
  129.  
  130. paste left.txt right.txt | column -s '␉' -t
  131.  
  132. while read line
  133. do
  134. echo ${#line}
  135. done < file1.txt | sort -n | tail -1
  136.  
  137. awk 'FS="---" {printf "%-22sn", $1}' < file1.txt > file1-pad.txt
  138.  
  139. $ paste file1-pad.txt file2.txt
  140. Languages Minimal automaton
  141. Recursively enumerable Turing machine
  142. Regular Finite
  143.  
  144. paste file1 file2 | sed 's/t/t/g' | column -s $'t' -t
  145.  
  146. paste file1 file2 | sed 's/t/ t/g' | column -s $'t' -t
  147.  
  148. paste file1 file2 | sed $'s/t/ t/g' | column -s $'t' -t
  149.  
  150. awk '
  151. NR==FNR { if (length > max_length) max_length = length
  152. max_FNR = FNR
  153. save[FNR] = $0
  154. next
  155. }
  156. { printf "%-*s", max_length+2, save[FNR]
  157. print
  158. }
  159. END { if (FNR < max_FNR) {
  160. for (i=FNR+1; i <= max_FNR; i++) print save[i]
  161. }
  162. }
  163. ' file1 file2
  164.  
  165. awk '
  166. FNR==1 { file_num++ }
  167. { if (length > max_length[file_num]) max_length[file_num] = length
  168. max_FNR[file_num] = FNR
  169. save[file_num,FNR] = $0
  170. }
  171. END { for (j=1; j<=file_num; j++) {
  172. if (max_FNR[j] > global_max_FNR) global_max_FNR = max_FNR[j]
  173. }
  174. for (i=1; i<=global_max_FNR; i++) {
  175. for (j=1; j<file_num; j++) printf "%-*s", max_length[j]+2, save[j,i]
  176. print save[file_num,i]
  177. }
  178. }
  179. ' file*
Add Comment
Please, Sign In to add comment