Get a value from a key=value file
Print the DB_HOST value from a .env file
sed -n 's/^DB_HOST=//p' .env
- tool
- sed15 commands
More sed commands
-
sed 's/foo/bar/' file.txtReplace the first "foo" with "bar" in each line
-
sed 's/foo/bar/g' file.txtReplace every match in each line with the /g flag
-
sed -i 's/old/new/g' config.cfgChange the file in place without a backup; on macOS use -i ''
-
sed -i.bak 's/old/new/g' file.txtEdit in place and keep the original as file.txt.bak
-
sed '/^#/d' config.txtDelete all comment lines that start with #