exporting a command
1 Attachment(s)
hi,
i am trying to export a cmd from .bash_profile file. Am getting the output as expected , but the content format is changing from original. Don't know why ?? PFA for my work around. Expected output like .. [root@server ~]# echo $a root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin |
Say a variable "CAT" exists in your bash profile file. It has the value of "cat".
Code:
[~]$ source .bashrc Code:
export CAT=cat |
hi mralk3,
did as suggested, still getting same output. |
Quote:
My apologies, I need to read in full. Quote:
|
This should work. There really is no reason to make a exported variable with this.
Code:
cat /etc/passwd | while read line ; do echo $line ; done |
Variable a is set correctly. You just need to quote it in the echo command to preserve that formatting:
Code:
echo "$a" |
BTW, you are not "exporting a command." When you run
Code:
a=`cat /etc/passwd` |
All times are GMT -5. The time now is 09:19 AM. |