The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

Views: 1,260β€…    Votes:  6β€…
Tags: command-line   bash   scripts   text  
Link: πŸ” See Original Answer on Ask Ubuntu πŸ”—

Title: Variable doesn't parse as string
ID: /2019/08/05/Variable-doesn_t-parse-as-string
Created: August 5, 2019    Edited:  August 5, 2019
Upload: November 24, 2022    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false

This works on my machine:

$ string="$(iwconfig wlp60s0 | grep -I Signal)"
$ echo $string
Link Quality=68/70 Signal level=-42 dBm
$ echo $string | cut -d' ' -f4,5
level=-42 dBm

You could also use:

$ echo $string | cut -d'=' -f3
-42 dBm

If you want to use ${string...} though the correct syntax is:

$ echo ${string##*=}
-38 dBm

$ echo "${string##*=}"
-38 dBm  

Either method will work to take the substring after the last =. The original method of 5 in your question I don’t understand how it can work.

⇧ Is it possible to patch without spiking the CPU? Freezing Games 18.04.1  β‡©