我有一个bash脚本,我希望将其作为命令全局运行。为此,我将脚本移至/usr/local/bin/somefile.sh
。
现在,我仍然必须调用一个名为somefile.sh
的命令。我想为此命令使用一个别名(例如,我只想使用命令sf
来调用脚本)。
我该怎么做?
答案 0 :(得分:2)
有不同的方法:
alias
,man alias
了解详情sf
的软链接答案 1 :(得分:2)
并补充@Kent的答案:
alias sf='/usr/local/bin/somefile.sh'
使用别名
ln -s somefile.sh /usr/local/bin/sf
使用软链接
mv /usr/local/bin/somefile.sh /usr/local/bin/sf
使用重命名
答案 2 :(得分:2)
打开位于.bashrc
的{{1}}文件。每当您登录系统时,都会读取~/.bashrc
文件。将以下行添加到文件末尾。
.bashrc
然后重新登录或运行alias sf='/usr/local/bin/somefile.sh'
答案 3 :(得分:1)
如果您使用的是GNU系统,则可以使用“替代”系统:
import requests
from bs4 import BeautifulSoup
import pandas as pd
headers = {'User-Agent':
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36'}
page = "https://www.transfermarkt.co.uk/transfers/transferrekorde/statistik/top/plus/0/galerie/0?saison_id=2000"
page1 = "https://www.transfermarkt.co.uk/transfers/transferrekorde/statistik/top/plus/0/galerie/0?saison_id=2018&land_id=157&ausrichtung=&spielerposition_id=&altersklasse=&leihe=&w_s=s"
page2 = "https://www.transfermarkt.co.uk/transfers/transferrekorde/statistik/top/plus/0/galerie/0?saison_id=2018&land_id=157&ausrichtung=&spielerposition_id=&altersklasse=&leihe=&w_s=s"
pageTree = requests.get(page, headers=headers)
pageSoup = BeautifulSoup(pageTree.content, 'html.parser')
Players = pageSoup.find_all("a", {"class": "spielprofil_tooltip"})
Values = pageSoup.find_all("td", {"class": "rechts hauptlink"})
#My Code for printing all 25 names and fees
#for i in range(0, 25):
#print(Players[i].text, Values[i].text)
PlayersList = []
ValuesList = []
for i in range(0,25):
PlayersList.append(Players[i].text)
ValuesList.append(Values[i].text)
df = pd.DataFrame({"Players":PlayersList,"Values":ValuesList})
print(df.head(25))
这将创建2个符号链接:
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.PeopleService.v1;
using Google.Apis.PeopleService.v1.Data;
public class GoogleContacts
{
private String m_client_secret = "......";
private String m_client_id = ".......apps.googleusercontent.com";
public GoogleContacts()
{
// Create OAuth credential.
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = m_client_id,
ClientSecret = m_client_secret
},
new[] { "profile", "https://www.googleapis.com/auth/contacts.readonly" },
"me",
CancellationToken.None).Result;
// Create the service.
var service = new PeopleServiceService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "My App",
});
// Groups list ////////////
ContactGroupsResource groupsResource = new ContactGroupsResource(service);
ContactGroupsResource.ListRequest listRequest = groupsResource.List();
ListContactGroupsResponse response = listRequest.Execute();
// eg to show name of each group
List<string> groupNames = new List<string>();
foreach (ContactGroup group in response.ContactGroups)
{
groupNames.Add(group.FormattedName);
}
///////////////
// Contact list ////////////
PeopleResource.ConnectionsResource.ListRequest peopleRequest =
service.People.Connections.List("people/me");
peopleRequest.PersonFields = "names,emailAddresses";
peopleRequest.SortOrder = (PeopleResource.ConnectionsResource.ListRequest.SortOrderEnum) 1;
ListConnectionsResponse people = peopleRequest.Execute();
// eg to show display name of each contact
List<string> contacts = new List<string>();
foreach (var person in people.Connections)
{
contacts.Add(person.Names[0].DisplayName);
}
///////////////
}
}