Help Needed on Script

Hi team,

I am looking to execute some command through xargs.

$cat testfile | grep myloc
alias myloc='cd /export/nfs-1sv-23/'

I am trying to execute that alias as soon as i cat and grep ?

I tried with

$cat testfile | grep myloc | xargs  

--> no luck ...

Can some one assist me with correct approach please .

My OS is RHEL6 and Solaris 10.

My Shell is Bash & Ksh.

You can try do it as follows:

cat testfile | grep myloc | xargs sed 's/=/ /g' |awk "{print $2}' | bash

What do you mean by no luck?

Thanks for the feedback ...

$ cat testfile | grep myloc | xargs sed 's/=/ /g' |awk '{print $2}' | bash 
sed: can't read alias: No such file or directory
sed: can't read myloc=cd /export/nfs-1sv-23/: No such file or directory

no luck --- tried with xarg and it did not work

Any more thoughts please ??

xargs?? Do you mean

eval `grep myloc testfile`

?

Hi think grep myloc  = grep cd export/nfs-1sv-23/ i think its wrong can u pls check it

it think should be grep "cd export/nfs-1sv-23/"

please can u be more specific like what are u try to to grep i mean are u trying to grep "some cd" or grep "somepath to file" commands from a file containing multiple

 

Here is what am planning / my need
We have a NFS mount point on each host - /export/nfs-1sv-23; this NFS mountpoint will be different on different hosts and like that I have 1500 hosts almost 100 NFS mount points are there connecting 1500 Hosts.
So we kept the alias in .profile [ our default shell is KSH ] so as soon as call myloc it will take me to /export/nfs-1sv-23. People who build those shells edited 1500 .profile files.. and kept the

But I want to Keep that same stuff in my .bashrc [ a single file that will be pushed to each host ] so its unique instead of me editing my .bashrc file ... i want to get that content from exisiting file and use it.

cat and grep needs to pass the output which needs to be excuted. Not sure how to acheive this

---------- Post updated at 11:01 PM ---------- Previous update was at 04:30 PM ----------

Can somebody help me please