首先,用下面的指令根據UID來排序A機器上面的帳號:
- sort -n -t ':' -k3 /etc/passwd
- sort -n -t ':' -k3 /etc/passwd | awk -F ":" '$3>=1111 {print}' | awk -F ":" '$3<=2222 {print}'
- sort -n -t ':' -k3 /etc/passwd | awk -F ":" '$3>=1111 {print}' | awk -F ":" '$3<=2222 {print $1}'
- sort -n -t ':' -k3 /etc/passwd | awk -F ":" '$3>=1111 {print}' | awk -F ":" '$3<=2222 {print $1}' | tr '\n' '|' | sed s'/.|$/\n/'
- sudo egrep -E `sort -n -t ':' -k3 /etc/passwd | awk -F ":" '$3>=1111 {print}' | awk -F ":" '$3<=2222 {print $1}' | tr '\n' '|' | sed s'/.|$/\n/'` /etc/shadow
參考資料
- How to shave off last character using sed?
- How to grep with a list of words
- How to use “:” as awk field separator?
- Grep lines for numbers greater than given number
沒有留言:
張貼留言