[Solved] Some troubles with using sed and awk [closed]

From what we can discern of this question, you’re attempting to create a programmatic rule to rename files ending in extensions stdout-captured, stderr-captured, and status-captured (assuming one typo) into files ending in extensions stdout-expected, stderr-expected, and status-expected, respectively. Obviously, if each of these definitions is inclusive of exactly one file, a rote mv may be … Read more

[Solved] Use awk to find letters and print results [closed]

I think you are looking for this: awk ‘/^[JM]/{print $1,$2}’ i_ve_got_an_vi_edirtor_with_some_collums.file update Now i need the same but only for students that the surname starts from [A-D] awk ‘$2~/^[A-D]/{print $1,$2}’ i_ve_got_an_vi_edirtor_with_some_collums.file 16 solved Use awk to find letters and print results [closed]

[Solved] awk printf with variable

Note that foo=4/3 sets foo to the string 4/3. When that is printed via %f, ‘4/3’ is treated as 4; when that is printed with %s, it is printed as 4/3. If you want to evaluate the expression, you need it evaluated inside the script. For example: awk ‘END {printf “%f\n”, foonum/fooden }’ foonum=4 fooden=3 … Read more

[Solved] shell script to backup system [closed]

Here is a solution that requires no subshell or external program, does not parse ls output (which is not recommended), and should work with filenames containing spaces (or even newlines). You can customize your prefix and extension. #!/bin/bash dir=”/path/to/files” prefix=”backup#” ext=”.tar.gz” max=1 for file in “$dir/$prefix”* do [[ $file =~ /$prefix([0-9]+)$ext$ ]] || continue n=”${BASH_REMATCH[1]}” … Read more

[Solved] zsh/bash string to array not working using parentheses

cat “73276948.sh” #!/bin/bash STR=”one two three” array=($STR) echo “${array[@]}” # prints: one two three echo “len: ${#array[@]}” # prints: len: 1 echo “1ST: ${array[0]}” # prints: one two three echo “2ND: ${array[1]}” # prints: one two three echo “3RD: ${array[2]}” # prints: one two three echo “Using loop:” for (( indx = 0; indx < … Read more

[Solved] How can I query the number of the virtual desktop on which the bash script is running in Linux Mint via bash?

Based on answer of KamilCuk, its possible to output on follow way the line which is including the number of the active desktop: nr_of_active_desktop=activedesktop=$(wmctrl -d | grep “*” | rev | cut -d ‘ ‘ -f1) echo $nr_of_active_desktop solved How can I query the number of the virtual desktop on which the bash script is … Read more