Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: edit.sh

Issue 29761555: #8852 - ldap sync output filter (Closed)
Left Patch Set: #8852 - ldap sync output filter Created May 14, 2018, 3 p.m.
Right Patch Set: #8852 - ldap sync output filter Created June 20, 2018, 12:32 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | output.txt » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #!/bin/sh 1 #!/bin/sh
2 #####################################################################
3 #####################################################################
4 ## The cause of this script is to make the output of the LDAP ##
5 ## sync cron job more readable by filtering all repeated lines ##
6 #####################################################################
7 #####################################################################
f.lopez 2018/05/15 00:51:19 "Filters out repeated lines from LDAP sync cron jo
8 2
9 last_updated="" 3 # Filter out uninformative output lines from the ldap-sync cron job script
10 4
11 while IFS= read -r line; do 5 last_action=""
f.lopez 2018/05/15 00:51:19 This IFS set is redundant here because you are quo
12 if echo "$line" | grep -q "Updating" ||
f.lopez 2018/05/15 00:51:19 can't you avoid repeating yourself here with the `
13 echo "$line" | grep -q "Creating"
14 then
15 last_updated="$line"
16 fi
17 6
18 if echo "$line" | grep -q -v "Updating" && 7 while read line; do
f.lopez 2018/05/15 00:51:19 You can use the `-F` flag for all lines so you don
19 echo "$line" | grep -q -v "Creating" && 8 case "$line" in
20 echo "$line" | grep -q -v "Found" && 9 *-\>*)
21 echo "$line" | grep -q -v "#" && 10 if [ ! -z "$last_action" ]
22 echo "$line" | grep -q -v "Synchronizing" && 11 then
23 echo "$line" | grep -q -v -F -e "->" 12 echo "$last_action"
24 then 13 fi
25 echo $line
f.lopez 2018/05/15 00:51:19 my editor shows an empty space at the end of this
26 fi
27 14
28 if echo "$line" | grep -q -F -e "->" 15 echo "$line"
f.lopez 2018/05/15 00:51:19 no need for `-F` flag since you are matching a sin
29 then 16 last_action=""
30 echo $last_updated 17 ;;
31 echo $line 18 --\ Found\ *\ users* | \
f.lopez 2018/05/15 00:51:19 Quote both lines here http://www.tldp.org/LDP/abs
32 fi 19 \#* | \
20 *Synchronizing\ *\ groups* | \
21 \*\*\ Synchronizing\ *\ users* | \
22 --\ Updating\ user\ \'*\'?\(*\)* | \
23 --\ Updating\ group\ \'*\'* | \
24 --\ Creating\ user\ \'*\'?\(*\)* | \
25 --\ Creating\ group\ \'*\'*)
26 last_action="$line"
27 ;;
28 *)
29 echo "$line"
30 ;;
31 esac
33 done 32 done
f.lopez 2018/05/15 00:51:19 add an empty line at the end of the file
LEFTRIGHT
« no previous file | output.txt » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld