SHARE
TWEET

Untitled

a guest May 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. set -euo pipefail
  4.  
  5. alphaNum() {
  6.         ls -1 tempKeys | sed '/_/ /g'
  7. }
  8. caseIgn() {
  9.         ls -1 tempKeysCase | sed 's/_/ /g'
  10. }
  11.  
  12. #if [ $# -eq 2 ]; then
  13. #       file=$3
  14. #
  15. #       else
  16. #       file=$1
  17. #fi
  18.  
  19. argCount=0
  20. token=false
  21. sepOpt=false
  22. keyOpt=false
  23. sep=" "
  24. flag1=zero
  25. flag2=zip
  26. flag3=nothing
  27. flag4=natta
  28.  
  29. for arg in "$@"; do
  30.         if [ $token == "true" ]; then
  31.                 #if [ $option == "-t" ]; then
  32.                 sep=$(echo "$arg")
  33.                 token=false
  34.                 #fi
  35.         fi
  36.         opt=$(echo "$arg" | head -c 2)
  37.         if [ $opt == "-t" ]; then
  38.                 #option=$(echo "-t")
  39.                 sepOpt=true
  40.                 token=true
  41.         elif [ $opt == "-k" ]; then
  42.                 #option=$(echo "-k")
  43.                 keyOpt=true
  44.                 echo "$arg"
  45.                 numbers=$(echo "$arg" | tr -c [0-9] " " | sed 's/ */ /')
  46.                 N=$(echo "$numbers" | cut -d " " -f 2)
  47.                 M=$(echo "$numbers" | cut -d " " -f 3)
  48.                 letters=$(echo "$arg" | tr -d [0-9] | cut -d "," -f 2)
  49.                 #echo "letters = $letters"
  50.                 count=$(echo "$letters" | wc -c)
  51.                 count=$((count-1))
  52.                 #echo "wc = $count"
  53.                 numFlags=$((count+1))
  54.                 while [ $count -gt 0 ]; do
  55.                         current=$(echo "$letters" | head -c $count | tail -c 1)
  56.                         eval "flag$count=$current"
  57.                         count=$((count-1))
  58.                 done
  59.         fi
  60.         argCount=$((argCount+1))
  61. done;
  62.  
  63. #echo "N = $N"
  64. #echo "M = $M"
  65.  
  66. temp='$'$argCount
  67. eval "file=$temp"
  68. directory=tempKeys
  69. mkdir $directory
  70.  
  71. while read -r line; do
  72.   if [ $keyOpt == "true" ]; then
  73.         temp=$(echo "$line" | cut -d "$sep" -sf $N-$M | sed 's/ /_/g')
  74.         if [ -n $temp ]; then
  75.                 echo "jsem v podmince"
  76.                 line=$(echo "$line" | cut -d "$sep" -f $N-$M | sed 's/ /_/g')
  77.         else
  78.                 line=$temp
  79.         fi
  80.   else
  81.         line=$(echo "$line" | sed 's/ /_/g')
  82.   fi
  83.   echo "touching $line"
  84.   touch $directory/$line
  85. done < $file
  86.  
  87. ls -1 $directory > keys_temp.txt
  88. rm -r $directory/*
  89.  
  90. echo "---------"
  91. cat keys_temp.txt
  92. echo "---------"
  93.  
  94. while read -r line; do
  95.   if [ $flag1 == "n" ] || [ $flag2 == "n" ] || [ $flag3 == "n" ] || [ $flag4 == "n" ]
  96.   then
  97.         # neco - doplnit nejakym znakem abych mohl tridit ciselne
  98.         echo "line before = $line"
  99.         charNum=$(echo "$line" | wc -m)
  100.         while [ $charNum -lt 33 ]; do
  101.                 line=$(echo "$line")
  102.                 charNum=$(($charNum+1))
  103.         done
  104.         echo "line after = $line"
  105.   else
  106.         if [ $flag1 == "b" ] || [ $flag2 == "b" ] || [ $flag3 == "b" ] || [ $flag4 == "b" ]
  107.         then
  108.                 #echo "line before = $line"
  109.                 line=$(echo "$line" | sed 's/ //g')
  110.                 #echo "line after = $line"
  111.         fi
  112.         if [ $flag1 == "f" ] || [ $flag2 == "f" ] || [ $flag3 == "f" ] || [ $flag4 == "f" ]
  113.         then
  114.                 #echo "line before = $line"
  115.                 line=$(echo "$line" | awk '{ print tolower($0) }')
  116.                 #echo "line after = $line"
  117.         fi
  118.   fi
  119.   touch $directory/$line
  120. done < keys_temp.txt
  121.  
  122. ls -1v $directory | sed 's/_/ /g'
  123. rm -r $directory
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top