How to store w3m dump result into a variable in a bash script? The result I got by w3m dump is
C: randomIP randomPORT randomUSERNAME randomPASSWORD
I want to cut "C:" and store everything else into variables so I can add it into a file.
Bash script: Store w3m dump into variable
335 Views Asked by Albert Karlsson At
2
There are 2 best solutions below
2
On
<your command> | read useless var1 var2 var3 var4
As explained in man read, read will (big surprise!) read a line on standard input (hence the pipe) and assign the given variables one by one using the IFS (by default the space character) as a delimiter in the input.
So in your example, useless will be assigned to "C:"; var1 to "randomIP"; ...
You can store any bash command output in this manner:-
Now
varvariable will consist of dump without "C:".