Advertisement
Guest User

Untitled

a guest
Sep 17th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.61 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. for i in $*;            #iterate through command args
  4. do
  5.     if [ $i = '-c' ] ||  [ $i = 'count' ];  
  6.     then
  7.        
  8.         shift
  9.         i=$1
  10.         lineCount=$i
  11.         shift
  12.     elif [ $i = '-p' ] ||  [ $i = '-permissions' ];
  13.     then
  14.         shift
  15.         i=$i
  16.         permissions=$i
  17.         shift
  18.     fi
  19.    
  20. done
  21.  
  22.  
  23. if [ -d '$@' ];             #Check if directory is valid
  24. then
  25.     filePath=$i
  26. else
  27.     echo $i is not a valid directory
  28.     exit 1
  29. fi
  30.  
  31.  
  32. if [[ $permissions = '' ]];
  33. then
  34.     permissions='-r'
  35. fi
  36.  
  37. if [[ $filePath = '' ]];
  38. then
  39.     permissions='.'
  40. fi
  41.  
  42. if [[ $lineCount = '' ]];
  43. then
  44.     lineCount=
  45.  
  46.  
  47. echo $permissions
  48. echo $lineCount
  49. echo $filePath
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement