<?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 Re: grep first and result to ls command in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377219#M35568</link>
    <description>Why I don,t want use the cd commad ? I'd prefer to have no modification on the current active path. &lt;BR /&gt;&lt;BR /&gt;About the idea: use /logs/forms/debug/before {}&lt;BR /&gt;&lt;BR /&gt;Example&lt;BR /&gt;find /logs/forms/debug/ -name "frm*" -exec grep -iq 'Error' {} \; -exec ls -lrt /logs/forms/debug/{} \; &lt;BR /&gt;&lt;BR /&gt;doesn't work of course. Probably I don't see want do want do. &lt;BR /&gt;&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den</description>
    <pubDate>Thu, 19 Mar 2009 11:42:26 GMT</pubDate>
    <dc:creator>Leo The Cat</dc:creator>
    <dc:date>2009-03-19T11:42:26Z</dc:date>
    <item>
      <title>grep first and result to ls command</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377213#M35562</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I'd like to combine grep and after that ls&lt;BR /&gt;&lt;BR /&gt;something like that&lt;BR /&gt;&lt;BR /&gt;grep -i "Error" frm*.txt | ls -lrt .......&lt;BR /&gt;&lt;BR /&gt;My result must be all grep files with Error but I want the same display provided by ls -lrt command to have by example date and time of these files !&lt;BR /&gt;&lt;BR /&gt;How to do this small trick !?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Any good idea ?&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Mar 2009 21:04:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377213#M35562</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-03-11T21:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: grep first and result to ls command</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377214#M35563</link>
      <description>Sorry of course the solution is:&lt;BR /&gt;&lt;BR /&gt;ls -lrt $(grep -il "Error" frm*)&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Mar 2009 21:28:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377214#M35563</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-03-11T21:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: grep first and result to ls command</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377215#M35564</link>
      <description>&lt;!--!*#--&gt;&amp;gt;  Sorry of course the solution is:&lt;BR /&gt;&amp;gt; [...]&lt;BR /&gt;&lt;BR /&gt;Except that "the solution" is, of course,&lt;BR /&gt;almost never more than "_a_ solution", and&lt;BR /&gt;this proposed solution may fail for very long&lt;BR /&gt;file lists.  Something like the following&lt;BR /&gt;might avoid some problems:&lt;BR /&gt;&lt;BR /&gt;find . -name 'frm*.txt' \&lt;BR /&gt; -exec grep -iq 'error' {} \; \&lt;BR /&gt; -exec ls -l {} \;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;(If "ls -l" output were not so lame, you&lt;BR /&gt;might even be able to sort the stuff by&lt;BR /&gt;date-time in a reasonable way.)&lt;BR /&gt;&lt;BR /&gt;Some "find" programs have a "-ls" operator,&lt;BR /&gt;which would simplify things a bit, too.  (The&lt;BR /&gt;one supplied with HP-UX seems not to be among&lt;BR /&gt;these.)</description>
      <pubDate>Thu, 12 Mar 2009 02:08:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377215#M35564</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-03-12T02:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: grep first and result to ls command</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377216#M35565</link>
      <description>Hi Guys &lt;BR /&gt;&lt;BR /&gt;ok. I'm in business now with the command below&lt;BR /&gt;&lt;BR /&gt;1. cd /logs/forms/debug/&lt;BR /&gt;&lt;BR /&gt;2. find . -name 'frm*' -exec grep -iq 'Error' {} \;  -exec ls -lrt {} \;  &amp;gt;&amp;gt; $OUTPUT_FILE &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;BUT !!&lt;BR /&gt;&lt;BR /&gt;I'd like to do this without the cd command. The problem is now &lt;BR /&gt;&lt;BR /&gt;find . -name '/logs/forms/debug/frm*' -exec grep -iq 'Error' {} \;  -exec ls -lrt {} \;  &amp;gt;&amp;gt; $OUTPUT_FILE &lt;BR /&gt;&lt;BR /&gt;doesn't work if I'm not running this from /logs/forms/debug/&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The situation is better !!! .... &lt;BR /&gt;&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den</description>
      <pubDate>Mon, 16 Mar 2009 17:26:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377216#M35565</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-03-16T17:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: grep first and result to ls command</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377217#M35566</link>
      <description>&lt;!--!*#--&gt;&amp;gt; I'd like to do this without the cd command.&lt;BR /&gt;&lt;BR /&gt;Why do you care?  What's the real problem?</description>
      <pubDate>Mon, 16 Mar 2009 19:54:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377217#M35566</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-03-16T19:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: grep first and result to ls command</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377218#M35567</link>
      <description>You're going about your find line the wrong way&lt;BR /&gt;the "." after find is path to search. -name just tells find what it's looking for.&lt;BR /&gt;&lt;BR /&gt;find /logs/forms/debug/ -name frm* -exec grep -iq 'Error' {} \; -exec ls -lrt {} \; &amp;gt;&amp;gt; $OUTPUT_FILE &lt;BR /&gt;&lt;BR /&gt;This is alot more likely to produce the result you're looking for. But I'm not entirely sure that find will return the full path (eg. /logs/forms/debug/frm1.file). Without the full path this will not work since neither of grep or ls will find the target.&lt;BR /&gt;&lt;BR /&gt;You can fix that by adding the path /logs/forms/debug/ before {}. Only do this is find doesn't give you a full path.&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Mar 2009 07:04:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377218#M35567</guid>
      <dc:creator>Fredrik.eriksson</dc:creator>
      <dc:date>2009-03-19T07:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: grep first and result to ls command</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377219#M35568</link>
      <description>Why I don,t want use the cd commad ? I'd prefer to have no modification on the current active path. &lt;BR /&gt;&lt;BR /&gt;About the idea: use /logs/forms/debug/before {}&lt;BR /&gt;&lt;BR /&gt;Example&lt;BR /&gt;find /logs/forms/debug/ -name "frm*" -exec grep -iq 'Error' {} \; -exec ls -lrt /logs/forms/debug/{} \; &lt;BR /&gt;&lt;BR /&gt;doesn't work of course. Probably I don't see want do want do. &lt;BR /&gt;&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den</description>
      <pubDate>Thu, 19 Mar 2009 11:42:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377219#M35568</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-03-19T11:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: grep first and result to ls command</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377220#M35569</link>
      <description>&lt;!--!*#--&gt;&amp;gt; Why I don,t want use the cd commad ? I'd&lt;BR /&gt;&amp;gt; prefer to have no modification on the&lt;BR /&gt;&amp;gt; current active path.&lt;BR /&gt;&lt;BR /&gt;As the old saying goes, there's more than one&lt;BR /&gt;way to skin a cat.&lt;BR /&gt;&lt;BR /&gt;bash$ pwd&lt;BR /&gt;/ALP$DKA0/sms&lt;BR /&gt;bash$ ( cd /tmp ; pwd )&lt;BR /&gt;/tmp&lt;BR /&gt;bash$ pwd&lt;BR /&gt;/ALP$DKA0/sms&lt;BR /&gt;&lt;BR /&gt;"man your_shell", look for "(".</description>
      <pubDate>Thu, 19 Mar 2009 11:59:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377220#M35569</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-03-19T11:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: grep first and result to ls command</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377221#M35570</link>
      <description>ok break !&lt;BR /&gt;&lt;BR /&gt;Why before I've used loop. It's because I need to add ### before each output line !&lt;BR /&gt;&lt;BR /&gt;like this:&lt;BR /&gt;cd /logs/forms/debug/&lt;BR /&gt;ls /logs/forms/debug/frmweb*&lt;BR /&gt;if [[ $? -eq 0 ]]; then &lt;BR /&gt;  for file in $(ls $(grep -il "Error" /logs/forms/debug/frmweb*))&lt;BR /&gt;  do&lt;BR /&gt;    echo "### " $(ls -l $file)  &amp;gt;&amp;gt; $OUTPUT_FILE &lt;BR /&gt;  done&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;And Unfortunately I didn't find the solution to do this with find and -exec (something like this)&lt;BR /&gt;&lt;BR /&gt;cd /logs/forms/debug/&lt;BR /&gt;find . -name 'frm*' -exec grep -iq 'Error' {} \;  -exec ls -lrt {} \;  &amp;gt;&amp;gt; $OUTPUT_FILE &lt;BR /&gt;&lt;BR /&gt;Where to manage the ### special string ?&lt;BR /&gt;&lt;BR /&gt;This is my problem, forget the "cd" command problem... it's not a problem here.&lt;BR /&gt;&lt;BR /&gt;Thank you very much&lt;BR /&gt;Den&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Mar 2009 16:58:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377221#M35570</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-03-20T16:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: grep first and result to ls command</title>
      <link>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377222#M35571</link>
      <description>&lt;!--!*#--&gt;&amp;gt; It's because I need to add ### before each&lt;BR /&gt;&amp;gt; output line !&lt;BR /&gt;&lt;BR /&gt;It certainly was foolish of me not to have&lt;BR /&gt;known that.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Where to manage the ### special string ?&lt;BR /&gt;&lt;BR /&gt;You could write a shell script, and have a&lt;BR /&gt;"-exec your_script" clause in your "find"&lt;BR /&gt;command.&lt;BR /&gt;&lt;BR /&gt;You could pipe the "find" output into a&lt;BR /&gt;sub-shell:&lt;BR /&gt;&lt;BR /&gt;bash$ ls -l&lt;BR /&gt;total 2&lt;BR /&gt;-rwxr-x---   1 SMS      40              5 Mar 20 13:48 a.b&lt;BR /&gt;-rw-r-----   1 SMS      40              5 Mar 20 13:49 a.c&lt;BR /&gt;-rw-r-----   1 SMS      40              5 Mar 20 13:49 a.d&lt;BR /&gt;-rwxr-x---   1 SMS      40              5 Mar 20  2009 b.c&lt;BR /&gt;bash$ cat ../fs.sh&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;find . -name 'a.*' -type f | \&lt;BR /&gt;(&lt;BR /&gt;    while read file ; do&lt;BR /&gt;        lsl=$( ls -l "$file" )&lt;BR /&gt;        echo "### ${lsl}"&lt;BR /&gt;    done&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;bash$ ../fs.sh&lt;BR /&gt;### -rwxr-x---   1 SMS      40              5 Mar 20 13:48 ./a.b&lt;BR /&gt;### -rw-r-----   1 SMS      40              5 Mar 20 13:49 ./a.c&lt;BR /&gt;### -rw-r-----   1 SMS      40              5 Mar 20 13:49 ./a.d&lt;BR /&gt;&lt;BR /&gt;Many things are possible.</description>
      <pubDate>Fri, 20 Mar 2009 17:59:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/grep-first-and-result-to-ls-command/m-p/4377222#M35571</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-03-20T17:59:10Z</dc:date>
    </item>
  </channel>
</rss>

