I want to store the last modified date of a file in a variable. I tried fileDate= date -r $file "+%Y-%m-%d" but the date command is printing the date instead of storing it in $fileDate. how do I do this?
            Asked
            
        
        
            Active
            
        
            Viewed 25 times
        
    0
            
            
         
    
    
        anas16
        
- 68
- 10
- 
                    Your command sets the variable `fileDate` to an empty string and then executes the `date` command in this environment. – user1934428 Feb 08 '22 at 14:16
- 
                    @user1934428 What do you mean by 'in this environment'. Can you please clarify? – anas16 Feb 08 '22 at 18:19
- 
                    1The environment in which the command runs. If you write a command `A=B C`, this execeutes the command C. `C` inherits the environment from the parent process, but with the slight modification, that the variable `A` in it is set to `B`. Note that you can also set more than one variable when running a child process, i.e. `X=1 Y=2 Z=3 C` runs `C` with the environment enhanced by X, Y and Z. – user1934428 Feb 09 '22 at 07:49