[InternetShortcut]URL=http://www.baidu.com/IDList=BEST=0[{000214A0-0000-0000-C000-000000000046}]Prop3=19,2
The above is the code for opening the Baidu shortcut file in text format saved in windows. The format of all URL files is basically the same. The first two lines are the same, and the following are slightly different.
The task is to get the URL and open it in a browser. You can use the following method to read a specified row from a shell script:
Cat $1 | awk 'nr = 2'
Or
Sed-N 2 p $1
$1 indicates the name of the input file. If you want to read the first line, replace the number with 2. The script to open the URL file is as follows:
# Cat $1 | awk 'nr = 2' | SED's/url = // G' | xargs Firefox
Sed-N 2 p $1 | SED's/url = // G' | xargs Firefox
Read the second line, replace url = with spaces, and start with Firefox. That is, it is equivalent to executing
Firefox http://www.baidu.com/
Save the preceding script as Openurl. SH and grant the running permission. In this case, run the following command on the command line to open the URL file:
./Openurl Baidu. url
It is inconvenient to continue. Right-click the URL file and choose another application to open it. The following window is displayed:
Select the custom command, and click browse to find our shell script file Openurl. Sh. Note that remember to open the file below... In this way, as long as you double-click the URL file, the following dialog box appears. Select Show to open the URL file in the browser.
However, after testing, some URL files are not valid. The reason is unclear. It may be related to the code after the second line in the URL or URL File code.