Filter a word : Shell Scripting
[root@daassna01vapp02 ~]# grep minlen /etc/pam.d/system-auth
password requisite pam_cracklib.so try_first_pass retry=3 minlen=8 difignore=8 lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1 [root@daassna01vapp02 ~]# How can I filter the word "minlen" and separate the number from "minlen=8" so that if condition can be applied to check the number given with "minlen=?". |
quick n dirty soln
Code:
grep minlen /etc/pam.d/system-auth |cut -d'=' -f3|cut -d' ' -f1 |
Thanks for replying chrism01, but I need to run the script for all my servers and its not necessary, everywhere the value is in the same field .
|
Independently from the position:
Code:
grep minlen /etc/pam.d/system-auth | awk -F= '/minlen/{print $NF}' RS=' ' Code:
if [[ $(grep minlen /etc/pam.d/system-auth | awk -F= '/minlen/{print $NF}' RS=' ') -eq 8 ]] |
tut tut tut ... I would not think I would see the day when colucix would combine a needless command ... lol
Code:
awk -F= '/minlen/{print $NF}' RS=' ' /etc/pam.d/system-auth |
Thanks for your replies Colucix and Grail. Your solutions worked :)
|
All times are GMT -5. The time now is 03:39 PM. |