Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- name: Romeo
- e_mail: letsrock@hotmail.com
- Room: 0/48
- street: 1/0/48
- name: April
- e_mail: thebestmonth@hotmail.com
- Room: 0/4
- street: 1/0/4
- name: Julian
- e_mail: julian688@gmail.com
- Room: 0/2
- street: 1/0/2
- name: Charles
- e_mail: charlesuniv@yahoo.com
- Room: 0/1
- street: 1/0/1
- name: Chris
- e_mail: todoras@hotmail.com
- Room: 0/42
- street: 1/0/42
- name: Richard
- e_mail: richiisfun@gmail.com
- Room: 0/6
- street: 1/0/6
- id,name,e_mail
- st0001, Romeo, letsrock@hotmail.com
- st0002, Julian, julian688@gmail.com
- st0003, Chris, todoras@hotmail.com
- st0004, Richard, richiisfun@gmail.com
- name: Romeo
- e_mail: letsrock@hotmail.com
- Room: 0/48
- street: 1/0/48
- id: st0001
- name: April
- e_mail: thebestmonth@hotmail.com
- Room: 0/4
- street: 1/0/4
- name: Julian
- e_mail: julian688@gmail.com
- Room: 0/2
- street: 1/0/2
- id: st0002
- name: Charles
- e_mail: charlesuniv@yahoo.com
- Room: 0/1
- street: 1/0/1
- name: Chris
- e_mail: todoras@hotmail.com
- Room: 0/42
- street: 1/0/42
- id: st0003
- name: Richard
- e_mail: richiisfun@gmail.com
- Room: 0/6
- street: 1/0/6
- id: st0004
- #!/bin/bash
- FILE1=students.dat
- FILE2=table.csv
- while read line; do
- if [[ $line == name* ]]; then
- echo -e "n$line"
- expectIp=1
- elif [[ $line == *e_mail* && $expectIp -eq 1 ]]; then
- sed 's/^s*//' <<< $line
- unset expectIp
- elif [[ $line == Room* ]]; then
- Room=$(echo $line | grep -o 'Room[^,]*,' | sed 's/,//')
- echo $Room
- echo $line | grep -o 'street*'
- justRoom=$(echo $Room | sed 's/Room: //')
- grep -A1 "$justRoom" $FILE2 | grep -o 'id'
- fi
- done < $FILE1
- grep "richiisfun@gmail.com" students.csv | awk -F ""*,"*" '{print $1}'
- perl -F',s+' -lane '
- @ARGV and $h{$F[1]}=$F[0],next;
- /^name:s+(S+)/ && exists $h{$a=$1} .. /^$/ || eof and do{
- /^$/ || eof and $_ .= (/^$/ ? $, : $) . ("id: " . $h{$a} // "") . (eof ? $, : $);
- };
- print;
- ' table.csv students.dat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement