[Solved] Bash: uppercase text inside html tag with sed

This will work only for your case and is not parsing HTML. DISCLAIMER First read: https://stackoverflow.com/a/1732454/7939871 This parsing with a sed Search-and-replace Regular Expression is a shortcut interpretation. It is in no way for use in any kind of production setup; as it would break on so many valid HTML syntax or layout variations like: … Read more

[Solved] How to improve the uniformly distributed of a given random function to generate uniformly distributed numbers? [closed]

what can be improved on a given random function to make it more random or for a bigger range or something else? and therefore no SRANDOM can be used up to now. How to improve the randomness of the fuction above, if possible ? Sooo write your own SRANDOM with your own semantics. Ex: srandom() … Read more

[Solved] Convert binary, octal, decimal and hexadecimal values between each other in BASH / Shell [duplicate]

Convert binary, octal, decimal and hexadecimal values between each other in BASH with bc and printf Some relevant Q&A: Understand “ibase” and “obase” in case of conversions with bc? TL;DR: ibase and obase params order matters, but not always. Hex values must be in UPPERCASE. Convert a character from and to its decimal, binary, octal, … Read more

[Solved] Grep text between patterns using bash [closed]

Sed can do it as follows: sed -n ‘/^======/{:a;N;/\n——/!ba;/score +/p}’ infile ====== Ann Smith score + —— where -n prevents printing, and /^======/ { # If the pattern space starts with “======” :a # Label to branch to N # Append next line to pattern space /\n——/!ba # If we don’t match “——“, branch to … Read more

[Solved] Sort words and then the sentence including digits and characters in Shell scripting or perl scripting [closed]

The algorithm to sort this problem is simple, just like you said in your question description, sort characters in each word first, then sort these sorted-word again. Like this: $ echo heya64 this is21 a good89 day91 | perl -anE ‘say(join ” “, sort(map { join “”, sort split // } @F))’ 12is 19ady 46aehy … Read more

[Solved] Want to read sequential lines in a file and do some mathematical calculation [closed]

Even though 5 persons down voted my question, I found my on way to solve the problem. Here is the code which I used. It is written in Python. enter codefrom numpy import * from math import * import operator f = open(‘Data_Genergy_26.txt’, ‘r’) lines = f.readlines() # initialize some variable to be lists: r … Read more

[Solved] How can I manipulate text in bash? [closed]

With awk: awk ‘BEGIN{FS=”[ ,]”; OFS=”,”} {for (i=2; i<=NF; i++) print $i,$1}’ file Output: foo,ted bar,ted zoo,ted ket,john ben,john See: 8 Powerful Awk Built-in Variables – FS, OFS, RS, ORS, NR, NF, FILENAME, FNR solved How can I manipulate text in bash? [closed]

[Solved] calculating average over many files [closed]

I forgot almost everything about bash scripting. but I think you can do something like this. files=(file1 file2 file3 file4) for i in `seq 4` do j=$(($i-1)) f[$j]=`cat ./temp/${files[$i]} | awk ‘{print $2}’ ` done for i in `seq 0 1799` do sum=0 rowValue=0 for j in `seq 0 3` do fileContent=(${f[$j]}) rowValue=`echo ${fileContent[$i]} ` … Read more

[Solved] reading properties from ini file in a bash script

It can be done pretty easily using Awk, just do the below to store the contents in a bash array. read -p “Enter object to get properties for: ” objectname all_properties=($(awk -F ‘=’ -v input=”${objectname}” ‘$1 ~ input{flag=1; next} $1 ~ /\[object/{flag=0; next} flag && NF {split($0,arr,”=”); print arr[2] } config.ini)) Now loop the array … Read more