osx - Bash + Replace string/value in column -
file: /etc/newsyslog.conf
i trying replace 3rd column (the count column) of each line. appears though first , second columns separated tabs. however, second , third columns separated spaces.
i can value of third column, each line, via:
grep /var /etc/newsyslog.conf | cut -d ' ' -f 3
however, having trouble setting/replacing value in third column. problem don't know value of third column given line. makes difficult, using method know, search/replace specific (third column) value/string.
thanks or advice may able offer.
edit: should have mentioned mac os 10.6 system.
better use awk here avoid multiple commands:
awk '/\/var/{print $3}'
edit:
awk 'begin{ofs="\t"} /\/var/{$3="14"}1' /etc/newsyslog.conf > temp mv temp /etc/newsyslog.conf
Comments
Post a Comment