<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Troubleshooting on Jaymin Patel</title><link>https://jayminpatel.elemprin.com/tags/troubleshooting/</link><description>Recent content in Troubleshooting on Jaymin Patel</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sun, 16 May 2010 11:25:00 +0530</lastBuildDate><atom:link href="https://jayminpatel.elemprin.com/tags/troubleshooting/index.xml" rel="self" type="application/rss+xml"/><item><title>Argument List Too Long</title><link>https://jayminpatel.elemprin.com/posts/2010-05-16-argument-list-too-long/</link><pubDate>Sun, 16 May 2010 11:25:00 +0530</pubDate><guid>https://jayminpatel.elemprin.com/posts/2010-05-16-argument-list-too-long/</guid><description>&lt;p>Suppose, there are 1,30,000 files to move from one directory to another, what will happen?&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># mv *.txt test&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Oh!! There is an error:&lt;/p>
&lt;pre tabindex="0">&lt;code>mv: Argument list too long.
&lt;/code>&lt;/pre>&lt;p>What to do? Simple answer is to use find command:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># find . -maxdepth 1 -name &amp;#39;*.txt&amp;#39; -exec mv &amp;#39;{}&amp;#39; test \;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Here,&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>Option&lt;/th>
 &lt;th>Description&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>&lt;code>.&lt;/code>&lt;/td>
 &lt;td>Defines search directory&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>-maxdepth&lt;/code>&lt;/td>
 &lt;td>Disables recursive search. With &lt;code>-maxdepth 1&lt;/code> it will only search in current directory&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>-name&lt;/code>&lt;/td>
 &lt;td>String to be searched&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>-exec&lt;/code>&lt;/td>
 &lt;td>Applies a command to set of files that have been searched&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>{}&lt;/code>&lt;/td>
 &lt;td>Inserts each found file into given command after &lt;code>-exec&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>\;&lt;/code>&lt;/td>
 &lt;td>Indicates the exec command line has ended&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;p>The above example searches for &lt;code>*.txt&lt;/code> files in current directory and moves it to the test directory.&lt;/p></description></item><item><title>bad interpreter: No such file or directory</title><link>https://jayminpatel.elemprin.com/posts/2010-05-16-bad-interpreter/</link><pubDate>Sun, 16 May 2010 11:21:00 +0530</pubDate><guid>https://jayminpatel.elemprin.com/posts/2010-05-16-bad-interpreter/</guid><description>&lt;p>Sometimes shell scripts in Linux give this error:&lt;/p>
&lt;pre tabindex="0">&lt;code>bash: ./t1.sh: /bin/sh^M: bad interpreter: No such file or directory
&lt;/code>&lt;/pre>&lt;p>This happens when files are transferred from a Windows machine to a Linux machine. Different operating systems use different line ending characters:&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>OS&lt;/th>
 &lt;th>Line End&lt;/th>
 &lt;th>Character&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>UNIX/Linux&lt;/td>
 &lt;td>LF&lt;/td>
 &lt;td>&lt;code>\n&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>DOS/Windows&lt;/td>
 &lt;td>CRLF&lt;/td>
 &lt;td>&lt;code>\r&lt;/code> and &lt;code>\n&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Mac&lt;/td>
 &lt;td>CR&lt;/td>
 &lt;td>&lt;code>\r&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;p>&lt;strong>CR&lt;/strong> (Carriage Return): Return cursor to left margin, Ctrl-M (^M) or hex 0D
&lt;strong>LF&lt;/strong> (Linefeed): Move cursor down, Ctrl-J (^J) or hex 0A&lt;/p></description></item></channel></rss>