Shell script to open the IE shortcut URL File

Source: Internet
Author: User
[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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.