<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic looking for command that would CD in first dir found. in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/looking-for-command-that-would-cd-in-first-dir-found/m-p/4352810#M61099</link>
    <description>I would like to know how i could pipe the result of a directory search to 'CD' so that upon finding the directory, it automatically goes into it.&lt;BR /&gt;&lt;BR /&gt;for example, i'm looking for directory called 'foobar', i know i have it somewhere, maybe even in more than 1 place, what i want to do is search for it&lt;BR /&gt;&lt;BR /&gt;find / -name "foobar" -type d&lt;BR /&gt;&lt;BR /&gt;AND, once it finds the location, the 'find' command displays where it found it, but i want to go further in my initial command and automatically CD to it.&lt;BR /&gt;&lt;BR /&gt;find / -name "foobar" -type d | cd&lt;BR /&gt;(that doesn't work)&lt;BR /&gt;&lt;BR /&gt;i've tried | cd %1 or $1 or $0, &lt;BR /&gt;&lt;BR /&gt;how can this be done?</description>
    <pubDate>Thu, 05 Feb 2009 15:13:35 GMT</pubDate>
    <dc:creator>Daniel Simard</dc:creator>
    <dc:date>2009-02-05T15:13:35Z</dc:date>
    <item>
      <title>looking for command that would CD in first dir found.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/looking-for-command-that-would-cd-in-first-dir-found/m-p/4352810#M61099</link>
      <description>I would like to know how i could pipe the result of a directory search to 'CD' so that upon finding the directory, it automatically goes into it.&lt;BR /&gt;&lt;BR /&gt;for example, i'm looking for directory called 'foobar', i know i have it somewhere, maybe even in more than 1 place, what i want to do is search for it&lt;BR /&gt;&lt;BR /&gt;find / -name "foobar" -type d&lt;BR /&gt;&lt;BR /&gt;AND, once it finds the location, the 'find' command displays where it found it, but i want to go further in my initial command and automatically CD to it.&lt;BR /&gt;&lt;BR /&gt;find / -name "foobar" -type d | cd&lt;BR /&gt;(that doesn't work)&lt;BR /&gt;&lt;BR /&gt;i've tried | cd %1 or $1 or $0, &lt;BR /&gt;&lt;BR /&gt;how can this be done?</description>
      <pubDate>Thu, 05 Feb 2009 15:13:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/looking-for-command-that-would-cd-in-first-dir-found/m-p/4352810#M61099</guid>
      <dc:creator>Daniel Simard</dc:creator>
      <dc:date>2009-02-05T15:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: looking for command that would CD in first dir found.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/looking-for-command-that-would-cd-in-first-dir-found/m-p/4352811#M61100</link>
      <description>You can use:&lt;BR /&gt;&lt;BR /&gt;cd $(find / -name "foobar" -type d)&lt;BR /&gt;&lt;BR /&gt;That is called command substitution.&lt;BR /&gt;&lt;BR /&gt;Also, remember that the find command may find more than one directory with the same name, then you must filter the results somehow, for example:&lt;BR /&gt;&lt;BR /&gt;cd $(find / -name "foobar" -type d | head -1)</description>
      <pubDate>Thu, 05 Feb 2009 15:17:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/looking-for-command-that-would-cd-in-first-dir-found/m-p/4352811#M61100</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2009-02-05T15:17:35Z</dc:date>
    </item>
  </channel>
</rss>

