title: Linux Shell Script: list contents of a directory into a file
body: <p>i have to write a shell script that gets a directory name as a parameter and then lists the names and sizes of the files in the directory into a text file. I have little knowledge of linux so can you please help me?</p>
  
  <p>All i managed to write is this:</p>
  
  <pre><code>for entry in "$search_dir"/* 
  do
    if [ -f "$entry" ];then
      echo "$entry"
    fi
  done
  </code></pre>
  
  <p>The output file should look like this:</p>
  
  <pre><code>filename1 filesize1
  filename2 filesize2
  </code></pre>
  
  <p>I have problems about getting the directory name as a parameter</p>