Guest User

Untitled

a guest
Oct 16th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. grep da * 2
  2.  
  3. # check command line arguments
  4. if [ $# -eq 0 ]
  5. then
  6. echo "wrong number of command line arguments"
  7. echo "Usage: `basename $0` -?"
  8. echo "
  9. or"
  10. echo "
  11. `basename $0` -d <file_to_be_deleted>"
  12. echo "
  13. or"
  14. echo "
  15. `basename $0` -f <text> <number_of_lines> <outfile>"
  16. exit
  17. fi
  18. if [ $# -eq 1 ]
  19. then
  20. if [ "$1" != "-?" ]
  21. then
  22. echo "incorrect command line argument: $1"
  23. fi
  24. echo "Usage: `basename $0` -?"
  25. echo "
  26. or"
  27. echo "
  28. `basename $0` -d <file_to_be_deleted>"
  29. echo "
  30. or"
  31. echo "
  32. `basename $0` -f <text> <number_of_lines> <outfile>"
  33. exit
  34. fi
  35. if [ $# -eq 2 ]
  36. then
  37. if [ "$1" == "-d" ]
  38. then
  39. echo "removing file $2"
  40. rm $2
  41. exit
  42. else
  43. echo "incorrect command line argument: $1"
  44. echo "Usage: `basename $0` -?"
  45. echo "
  46. or"
  47. echo "
  48. `basename $0` -d <file_to_be_deleted>"
  49. echo "
  50. or"
  51. echo "
  52. `basename $0` -f <text> <number_of_lines> <outfile>"
  53. exit
  54. fi
  55. fi
  56. if [ $# -eq 3 ]
  57. then
  58. echo "wrong number of command line arguments"
  59. echo "Usage: `basename $0` -?"
  60. echo
  61. echo
  62. echo
  63. echo
  64. exit
  65. if [ $# -eq 4 ]
  66. then
  67. if [ "$1" != "-f" ]
  68. then
  69. echo "incorrect command line argument: $1"
  70. echo "Usage: `basename $0` -?"
  71. echo "
  72. or"
  73. echo "
  74. `basename $0` -d <file_to_be_deleted>"
  75. echo "
  76. or"
  77. echo "
  78. `basename $0` -f <text> <number_of_lines> <outfile>"
  79. exit
  80. fi
  81. fi
  82. if [ $# -gt 4 ]
  83. then
  84. echo "wrong number of command line arguments"
  85. echo "Usage: `basename $0` -?"
  86. echo "
  87. or"
  88. echo "
  89. `basename $0` -d <file_to_be_deleted>"
  90. echo "
  91. or"
  92. echo "
  93. `basename $0` -f <text> <number_of_lines> <outfile>"
  94. exit
  95. fi
  96. # so the command line arguments are OK
  97. # redirect standard output to $4
  98. >$4
  99. # loop through and create the lines and ad them to $4
  100. for ((i=1; i<=$3; i++))
  101. do
  102. echo "$2**$i">>$4
  103. done
  104. # show the created file
  105. cat $4
Add Comment
Please, Sign In to add comment