r_dwssap.sh 1

r_dwssap.sh

cat -e /etc/passwd | grep -v '^#' | awk 'NR % 2 == 0' | awk -F : '{ print $1 }' | rev | tail -r | awk -v ln1=$FT_LINE1 -v ln2=$FT_LINE2 'NR >= ln1 && NR <= ln2' | awk '{ printf $0", " }' | sed 's/.\{2\}$/./'

Here is what the above code is Doing:
1. cat -e /etc/passwd | grep -v '^#' | awk 'NR % 2 == 0'
- cat -e /etc/passwd: prints the contents of /etc/passwd with $ at the end of each line
- grep -v '^#': removes all lines that start with #
- awk 'NR % 2 == 0': removes all odd lines
2. awk -F : '{ print $1 }'
- awk -F : '{ print $1 }': prints the first field of each line (the username)
3. rev | tail -r
- rev: reverses the order of the lines
- tail -r: reverses the order of the lines
4. awk -v ln1=$FT_LINE1 -v ln2=$FT_LINE2 'NR >= ln1 && NR <= ln2' - awk -v ln1=$FT_LINE1 -v ln2=$FT_LINE2 'NR >= ln1 && NR <= ln2': prints the lines between FT_LINE1 and FT_LINE2 5. awk '{ printf $0", " }' - awk '{ printf $0", " }': prints the lines with a comma and a space at the end 6. sed 's/.\{2\}$/./' - sed 's/.\{2\}$/./': removes the last comma and space

Similar Posts