Wednesday, May 23, 2012

How to assign a password present in a file to a variable ?

Let's say you have a file 'secretfile' which contains the password 'newpass'. You want to assign the password mentioned in that file to a variable called 'pass1'.  The syntax will go like this:

# cat  secretfile
newpass

Method 1
# pass1=$(cat secretfile)
# echo $pass1
newpass

Method 2
# read pass1 < secretfile
# echo $pass1
newpass

No comments:

Post a Comment

Popular Posts

About Me

My photo
The intent of this blog is to share my work experience and spread some smart solutions on Linux to System Administrators. I'm hoping the solutions shared in this Blog would be helpful and come as a handy for Viewers. Brief about me: I have 18+ years work experience in System and Cloud Administration domain, primarily works on VMware Cloud Products (vSphere, vCloud Director, vRealize Automation, NSX Adv. Load Balancer, vROps).