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
    649
    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. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,391
    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.

  5. #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 ?

  6. #6
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,567
    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
    What do we want?
    Time machines!

    When do we want 'em?
    Doesn't really matter does it!?


    The Fifth Continent

  7. #7
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    649
    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
  •