Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I have to take the $4 parameter, divide it equally by $2 parameter (If it cant be divided equally, add spaces to fill last part) and put every part at the end of randomized files we just created with
$4
$2
dir=$3 mkdir -p -- "$dir" || exit 1 fname=$(shuf -n 1 "$1") tr -dc 'A-Za-z0-9' dev/urandom | head -c 255 >"$dir/$fname"
It looks like this:
script.sh process>.
script.sh process>
The number of files created depends on how many divided parts of the $4 by $2. Basically I need to equally hide part of process> in randoms files which will be in . Also would it be easier to process files in the meantime so they can be sorted alphabetically in ?
process>
Example : script.sh 3 this will be divided .There "this will be divided" will be equally seperated in parts of 3 characters "thi" "s w" "ill" " be" " di" "vid" "ed ". In this example I needed to add a space at the end of ed. I will then send each individual parts at the end of my randomized files.
script.sh 3 this will be divided
ed
This routine should solve your string-splitting task. Adapt to your needs:
$ cat go.sh #!/usr/bin/env bash str="This will be divided" ptr=0 interval=3 while [[ $ptr -le ${#str} ]]; do printf "'%-3s'\n" "${str:$((ptr)):$((interval))}" ptr=$((ptr+interval)) done
In use:
$ ./go.sh 'Thi' 's w' 'ill' ' be' ' di' 'vid' 'ed '
This uses bash's built in parameter expansion tooling for substring extraction. Given a variable foo:
bash
foo
$foo
${#foo}
foo=10; echo ${#foo}
2
${foo:4:4}
The last of these is the key here: We use our string, a pointer for how many characters we've printed so far, and a defined interval.
We combine this with formated strings: %-3s will output a left-justified, space-padded string. So if we provide only one or two characters, space padding is added to the right for us.
%-3s
To write to files, you can simply change
printf "'%-3s'\n" "${str:$((ptr)):$((interval))}"
to
fname="$dir/$(shuf -n 1 "$1")" tr -dc 'A-Za-z0-9' dev/urandom | head -c 255 > "$fname" printf "'%-3s'\n" "${str:$((ptr)):$((interval))}" >> "$fname"
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 9 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.