insert output of sed into a variable
Hi,
This is a shell-related question. I would like to insert the ip address of the current x-server into a variable. If the Xdmcp-server and x-server are not the same computer, it looks like $DISPLAY gives <ip-adress>:<display-id> . for example: 192.168.0.31:0.0 Is it possible to remove the ':0.0' from $DISPLAY (probably with sed) and insert it into a new variable, like $DISPLAYHOST? I allready searched the web for it, but I can't find any solution. (I would like to run programs on the x-server while having a display of a different computer) Thanks in advance |
You can convert the output of any shell command or pipeline to a string by using backquotes (`).
For example, say you wanted to use some l33t encryption on some data, then send it to a variable for later use. Code:
$ export SECRETDATA=`echo data | rot13` Code:
$ export $DISPLAYHOST=`echo $DISPLAY | cut -f1 -d:` |
That worked .
THank you very much! Greetings Hendrik |
There are several way to do many things. Such a simple variable substitution could be done in bash.
export $DISPLAYHOST="${DISPLAY%:*}" If you wanted the DISPLAY#.SCREEN part: export $DISPLAYHOST="${DISPLAY#*:}" |
All times are GMT -5. The time now is 06:02 PM. |