0

I can extract umask value from new instance bash shell with this method :

[ansible@rhel8 ~]$ umask
0027
[ansible@rhel8 ~]$ bash
[ansible@rhel8 ~]$ umask
0002
[ansible@rhel8 ~]$ 

But for me this is inefficient way, so I want to make it efficient by using single command to extract umask value from new instance shell.

I try to use single command bash -c "umask" to extract umask in new instance shell, but I think this is not working as I expected, it shows umask of the current shell:

[ansible@rhel8 ~]$ umask
0027
[ansible@rhel8 ~]$ bash
[ansible@rhel8 ~]$ umask
0002
[ansible@rhel8 ~]$ exit
exit
[ansible@rhel8 ~]$ bash -c "umask"
0027
[ansible@rhel8 ~]$

So the question is, how I can achieve umask from the new instance shell with single command ??

3
  • 1
    a single line: showumask=`umask`; echo $showumask - putting the command in \´ command` executes it before using.
    – djdomi
    Commented Apr 8 at 7:54
  • 2
    If the new umask value is set in .bashrc, try adding the -i switch, like this: bash -ci "umask"
    – Lacek
    Commented Apr 8 at 7:59
  • Thank you @Lacek, this is what I want to achieve. Commented Apr 9 at 6:31

0

You must log in to answer this question.

Browse other questions tagged .