Advertisement
Guest User

Untitled

a guest
Mar 31st, 2017
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. name: Romeo
  2. e_mail: letsrock@hotmail.com
  3. Room: 0/48
  4. street: 1/0/48
  5.  
  6. name: April
  7. e_mail: thebestmonth@hotmail.com
  8. Room: 0/4
  9. street: 1/0/4
  10.  
  11. name: Julian
  12. e_mail: julian688@gmail.com
  13. Room: 0/2
  14. street: 1/0/2
  15.  
  16. name: Charles
  17. e_mail: charlesuniv@yahoo.com
  18. Room: 0/1
  19. street: 1/0/1
  20.  
  21. name: Chris
  22. e_mail: todoras@hotmail.com
  23. Room: 0/42
  24. street: 1/0/42
  25.  
  26. name: Richard
  27. e_mail: richiisfun@gmail.com
  28. Room: 0/6
  29. street: 1/0/6
  30.  
  31. id,name,e_mail
  32. st0001, Romeo, letsrock@hotmail.com
  33. st0002, Julian, julian688@gmail.com
  34. st0003, Chris, todoras@hotmail.com
  35. st0004, Richard, richiisfun@gmail.com
  36.  
  37. name: Romeo
  38. e_mail: letsrock@hotmail.com
  39. Room: 0/48
  40. street: 1/0/48
  41. id: st0001
  42.  
  43. name: April
  44. e_mail: thebestmonth@hotmail.com
  45. Room: 0/4
  46. street: 1/0/4
  47.  
  48. name: Julian
  49. e_mail: julian688@gmail.com
  50. Room: 0/2
  51. street: 1/0/2
  52. id: st0002
  53.  
  54. name: Charles
  55. e_mail: charlesuniv@yahoo.com
  56. Room: 0/1
  57. street: 1/0/1
  58.  
  59. name: Chris
  60. e_mail: todoras@hotmail.com
  61. Room: 0/42
  62. street: 1/0/42
  63. id: st0003
  64.  
  65. name: Richard
  66. e_mail: richiisfun@gmail.com
  67. Room: 0/6
  68. street: 1/0/6
  69. id: st0004
  70.  
  71. #!/bin/bash
  72.  
  73. FILE1=students.dat
  74. FILE2=table.csv
  75.  
  76. while read line; do
  77. if [[ $line == name* ]]; then
  78. echo -e "n$line"
  79. expectIp=1
  80. elif [[ $line == *e_mail* && $expectIp -eq 1 ]]; then
  81. sed 's/^s*//' <<< $line
  82. unset expectIp
  83. elif [[ $line == Room* ]]; then
  84. Room=$(echo $line | grep -o 'Room[^,]*,' | sed 's/,//')
  85. echo $Room
  86. echo $line | grep -o 'street*'
  87. justRoom=$(echo $Room | sed 's/Room: //')
  88. grep -A1 "$justRoom" $FILE2 | grep -o 'id'
  89. fi
  90. done < $FILE1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement