Вопрос

There is a file in my home directory named conkyrc now this controls my whole of conky setup & there is a nice internet speed meter on my desktop but the problem is that my OS is on a portable drive that is connected to various different places (thus having various network internet access points) so I have to manually replace the keyword for current access point in this conkyrc file (for instance eth5 for eth3).

Now this action can be done by opening file in any text editor & using search/replace...but for triviality I want to create a simple bash script which asks user for proper access point & auto replaces instances of say eth5 for eth3, eth3 being the current user input.

Also a zenity simplistic gui asking for user input is welcome.

Это было полезно?

Решение

#!/bin/bash
if  eth=$(zenity --entry --text="Enter the access point") &&
    [[ $eth =~ ^eth[0-9]$ ]]
then
     sed -i "s/\<eth[0-9]\>/$eth/" ~/conkyrc
fi
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top