Whatever the umask value I want to change it into umask 077
dynamically.
sed -d 's/umask [0-999]/umask 077/g' /etc/bashrc,
I have tried the above one but it's not working.
Whatever the umask value I want to change it into umask 077
dynamically.
sed -d 's/umask [0-999]/umask 077/g' /etc/bashrc,
I have tried the above one but it's not working.
You can use
sed -i 's/\(umask \)[0-9]\{1,\}/\1 077/g' /etc/bashrc
It means
-i
- the /etc/bashrc
will be changed inline\(umask \)[0-9]\{1,\}
- the regex pattern that matches
\(umask \)
- Group 1: umask
+ space[0-9]\{1,\}
- 1 or more occurrences of any ASCII digit\1 077
- the contents of Group 1, space, 077
g' -
global` modifier, match and replace all non-overlapping occurrences.