Find the answer to your Linux question:
Results 1 to 7 of 7
Hi, how can I use the output of "locate php.ini" as the argument of vi ?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2013
    Posts
    34

    use output


    Hi,

    how can I use the output of "locate php.ini" as the argument of vi ?

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    673
    Code:
    vi $(locate php.ini)

  3. #3
    Just Joined!
    Join Date
    Feb 2013
    Posts
    34
    Why this doesn't work ?

    Code:
    locate php.ini | vi

  4. $spacer_open
    $spacer_close
  5. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,439
    Because vi expects a parameter and you instead pipe the path(s)+filename(s) to stdin
    You must always face the curtain with a bow.

  6. #5
    Just Joined!
    Join Date
    Feb 2013
    Posts
    34
    Quote Originally Posted by Irithori View Post
    Because vi expects a parameter and you instead pipe the path(s)+filename(s) to stdin
    Isn't path+filename the parameter that vi expects ?

  7. #6
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,649
    Quote Originally Posted by umbloaded View Post
    Isn't path+filename the parameter that vi expects ?
    Yes, but it expects them as command line parameters not as input from stdin
    "I used to be with it, then they changed what it was.
    Now what was it isn't it, and what is it is weird and scary to me.
    It'll happen to you too."

    Grandpa Simpson



    The Fifth Continent

  8. #7
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    673
    This is supplying the location information on stdin and vi is expecting editing commands on standard input (stdin) and the file(s) to edit as arguments. The "$( command )" placed the standard output (stdout) of the command in place of the "$(command)" before bash starts the command.'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •