请问英汉语句子成分口诀“you are a grap of sb”用汉语怎么读?

How can I get distribution name and version number in a simple shell script? - Unix & Linux Stack Exchange
to customize your list.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. J it only takes a minute:
Here's how it works:
Anybody can ask a question
Anybody can answer
The best answers are voted up and rise to the top
I'm working on a simple bash script that should be able to run on Ubuntu and CentOS distributions (support for Debian and Fedora/RHEL would be a plus) and I need to know the name and version of the distribution the script is running (in order to trigger specific actions, for instance the creation of repositories). So far what I've got is this:
OS=$(awk '/DISTRIB_ID=/' /etc/*-release | sed 's/DISTRIB_ID=//' | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
VERSION=$(awk '/DISTRIB_RELEASE=/' /etc/*-release | sed 's/DISTRIB_RELEASE=//' | sed 's/[.]0/./')
if [ -z "$OS" ]; then
OS=$(awk '{print $1}' /etc/*-release | tr '[:upper:]' '[:lower:]')
if [ -z "$VERSION" ]; then
VERSION=$(awk '{print $3}' /etc/*-release)
echo $ARCH
echo $VERSION
This seems to work, returning ubuntu or centos (I haven't tried others) as the release name. However, I have a feeling that there must be an easier, more reliable way of finding this out -- is that true?
It doesn't work for RedHat.
/etc/redhat-release contains :
Redhat Linux Entreprise release 5.5
So, the version is not the third word, you'd better use :
OS_MAJOR_VERSION=`sed -rn 's/.*([0-9])\.[0-9].*/\1/p' /etc/redhat-release`
OS_MINOR_VERSION=`sed -rn 's/.*[0-9].([0-9]).*/\1/p' /etc/redhat-release`
echo "RedHat/CentOS $OS_MAJOR_VERSION.$OS_MINOR_VERSION"
12.1k62242
Most recent distributions have a tool called lsb_release.
Your /etc/*-release will be using /etc/lsb-release anyway, so if that file is there, running lsb_release should work too.
I think uname to get ARCH is still the best way.
OS=$(lsb_release -si)
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
VER=$(lsb_release -sr)
Or you could just source /etc/lsb-release:
. /etc/lsb-release
OS=$DISTRIB_ID
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
VER=$DISTRIB_RELEASE
If you have to be compatible with older distributions, there is no single file you can rely on.
Either fall back to the output from uname, e.g.
OS=$(uname -s)
ARCH=$(uname -m)
VER=$(uname -r)
or handle each distribution separately:
if [ -f /etc/debian_version ]; then
# XXX or Ubuntu??
VER=$(cat /etc/debian_version)
elif [ -f /etc/redhat-release ]; then
Of course, you can combine all this:
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
if [ -f /etc/lsb-release ]; then
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# XXX or Ubuntu??
VER=$(cat /etc/debian_version)
elif [ -f /etc/redhat-release ]; then
# TODO add code for Red Hat and CentOS here
OS=$(uname -s)
VER=$(uname -r)
Finally, your ARCH obviously only handles Intel systems.
I'd either call it BITS like this:
case $(uname -m) in
Or change ARCH to be the more common, yet unambiguous versions: x86 and x64 or similar:
case $(uname -m) in
# or AMD64 or Intel64 or whatever
# or IA32 or Intel32 or whatever
# leave ARCH as-is
but of course that's up to you.
30.2k973103
I'd go with this as a first step:
ls /etc/*release
Gentoo, RedHat, Arch & SuSE have a file called e.g. /etc/gentoo-release. Seems to be popular, check this site about .
Debian & Ubuntu should have a /etc/lsb-release which contains release info also, and will show up with the previous command.
Another quick one is uname -rv. If the kernel installed is the stock distro kernel, you'll usually sometimes find the name in there.
31.2k597116
lsb_release -a. Works on Debian and I guess Ubuntu, but I'm not sure about the rest. Normally it should exist in all GNU/Linux distributions since it is LSB (Linux Standard Base) related.
lsb-* isn't installed/doesn't exist on base CentOS or Debian systems
/proc/* doesn't exist on OSX
Take a tip from javascript developers.
Don't test for the version, test for the capability.
It's not pretty, but it works.
Expand as necessary.
function os_type
case `uname` in
which yum && { }
which zypper && { }
which apt-get && { }
# Handle AmgiaOS, CPM, and modified cable modems here.
One-liner, fallbacks, one line of output, no errors.
lsb_release -ds 2&/dev/null || cat /etc/*release 2&/dev/null | head -n1 || uname -om
Most of the time lsb_release -a or lsb_release -si will work.
Or you can use a script like this to handle the case where lsb_release is not available.
if [ -f /etc/lsb-release ]; then
. /etc/lsb-release
DISTRO=$DISTRIB_ID
elif [ -f /etc/debian_version ]; then
DISTRO=Debian
# XXX or Ubuntu
elif [ -f /etc/redhat-release ]; then
DISTRO="Red Hat"
# XXX or CentOS or Fedora
DISTRO=$(uname -s)
echo "$DISTRO"
If you're typing it interactively, and so prefer something easy to type, and don't care what the output is, you can just do.
lsb_release -sd || cat /etc/*release
30.2k973103
In order of most probable success, these:
cat /etc/*version
cat /proc/version #linprocfs/version for FreeBSD when "linux" enabled
cat /etc/*release
cover most cases (AFAIK): Debian, Ubuntu, Slackware, Suse, Redhat, Gentoo, *BSD and perhaps others.
If the file /etc/debian_version exists, the distribution is Debian, or a Debian derivative. This file may h on my machine it is currently 6.0.1. If it is testing or unstable, it may say testing/unstable, or it may have the number of the upcoming release. My impression is that on Ubuntu at least, this file is always testing/unstable, and that they don't put the release number in it, but someone can correct me if I am wrong.
Fedora (recent releases at least), have a similar file, namely /etc/fedora-release.
18k1257100
python -c "print(platform.platform())"
2 ways from many:
lsb_release -a
I tested it on CentOS 5.5 and Ubuntu 10.04
the output for CentOS is:
LSB Version:
:core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description:
CentOS release 5.5 (Final)
and for Ubuntu is:
LSB Version:
:core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description:
CentOS release 5.5 (Final)
2) enter the following command:
cat /etc/*-release
I tested it on CentOS 5.5 and Ubuntu 10.04, and it works fine.
1,18221227
For most modern Linux OS systems, the file /etc/os-release is really becoming standard and is getting included in most OS. So inside your Bash script you can just include the file, and you will have access to all variables described
(for example: NAME, VERSION, ...)
So I'm just using this in my Bash script:
if [ -f /etc/os-release ]
. /etc/os-release
echo "ERROR: I need the file /etc/os-release to determine what my distribution is..."
# If you want, you can include older or distribution specific files here...
If you can't or don't want to use the LSB release file (due to the dependencies the package brings in), you can look for the distro-specific release files.
has a probe for the distro you might be able to use:
12.7k12843
This script works on Debian, (may need some tweak on Ubuntu)
#!/usr/bin/env bash
echo "Finding Debian/ Ubuntu Codename..."
CODENAME=`cat /etc/*-release | grep "VERSION="`
CODENAME=${CODENAME##*\(}
CODENAME=${CODENAME%%\)*}
echo "$CODENAME"
# =& saucy, precise, lucid, wheezy, squeeze
Here is my simple chech_distro version. ^^;
#!/usr/bin/env bash
check_distro2(){
if [[ -e /etc/redhat-release ]]
DISTRO=$(cat /etc/redhat-release)
elif [[ -e /usr/bin/lsb_release ]]
DISTRO=$(lsb_release -d | awk -F ':' '{print $2}')
elif [[ -e /etc/issue ]]
DISTRO=$(cat /etc/issue)
DISTRO=$(cat /proc/version)
check_distro2
echo $DISTRO
Without version, just only dist:
cat /etc/issue | head -n +1 | awk '{print $1}'
Type below command
cat /etc/issue
This command works for Debian based and Redhat based distributions:
Using tr filter, you convert the document to one-word-per-line format and then count the first line which contains the distribution name.
tr -s ' \011' '\012' & /etc/issue | head -n 1
5,12451939
This was tested on Ubuntu 14 and CentOS 7
cat /etc/os-release | grep "PRETTY_NAME" | sed 's/PRETTY_NAME=//g' | sed 's/["]//g' | awk '{print $1}'
I find a good script
which works for most of common linux dists:
#! /bin/bash
# return an awkable string consisting of
unix OS type, or
Linux dist, or
a long guess (based on /proc), or
giveUp () {
echo "Unknown"
# keep this easily awkable, prepending an initial clue
versionGuess () {
if [ -e /proc/version ]; then
echo -n "Unsure "
cat /proc/version
# if we have ignition, print and exit
gotDist () {
[ -n "$1" ] && echo "$1" && exit 0
# we are only interested in a single word "dist" here
# various mal admin will have to code appropately based on output
linuxRelease () {
if [ -r /etc/lsb-release ]; then
dist=$(grep 'DISTRIB_ID' /etc/lsb-release | sed 's/DISTRIB_ID=//' | head -1)
gotDist "$dist"
dist=$(find /etc/ -maxdepth 1 -name '*release' 2& /dev/null | sed 's/\/etc\///' | sed 's/-release//' | head -1)
gotDist "$dist"
dist=$(find /etc/ -maxdepth 1 -name '*version' 2& /dev/null | sed 's/\/etc\///' | sed 's/-version//' | head -1)
gotDist "$dist"
# start with uname and branch the decision from there
dist=$(uname -s 2& /dev/null)
if [ "$dist" = "Linux" ]; then
linuxRelease
versionGuess
elif [ -n "$dist" ]; then
echo "$dist"
versionGuess
# we shouldn't get here
protected by
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10
on this site (the ).
Would you like to answer one of these
Not the answer you're looking for?
Browse other questions tagged
rev .24885
Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group. This site is not affiliated with Linus Torvalds or The Open Group in any way.
Unix & Linux Stack Exchange works best with JavaScript enabled下载作业帮安装包
扫二维码下载作业帮
1.75亿学生的选择
I'm proud of you的同意句爱好英语的朋友们,谁知道这个答案?我要求朋友们帮忙给的答案是这种形式的:You are______.这个空格应该填什么.
I`m the pride of youYou are a pride of me.be a pride of sb.……引以自豪的对象
为您推荐:
其他类似问题
I take pride in you.
you are the pride of mine.按你的说法应该是:You are (my pride)
I'm speaking highly of you.you are the best.you are perfect.
be proud of = take pride in故:I take pride in you.
扫描下载二维码Javascript must be enabled for the correct page display
Street photographer’s rights
Can I take a photograph in public that contains images of people I don&t know? Can I take a photo of a famous landmark or of the front of someone&s house and later sell it? Read on to find out!
In this information sheet:
Can I take a photograph in public that contains images of people I don&t know? Can I take a photo of a famous landmark or of the front of someone&s house and later sell it?
This information sheet aims to provide you with the answers to these and other questions that may arise when you are taking photographs in and of public spaces. It also aims to provide those you encounter with a statement of your rights to minimise the possibility of harassment or threatened legal action. So carry this in your pocket and be prepared.&
Taking photos in a public place
Photography on private property
Can taking photos be a criminal offence?
Photography of landmarks, buildings, monuments&
Use/publication of photographs
Download Information Sheet
Need more help?
If you have questions about any of the topics discussed above please .
Disclaimer
The information in this information sheet is general. It does not constitute, and should be not relied on as, legal advice. The Arts Law Centre of Australia (Arts Law) recommends seeking advice from a qualified lawyer on the legal issues affecting you before acting on any legal matter.
While Arts Law tries to ensure that the content of this information sheet is accurate, adequate or complete, it does not represent or warrant its accuracy, adequacy or completeness. Arts Law is not responsible for any loss suffered as a result of or in relation to the use of this information sheet. To the extent permitted by law, Arts Law excludes any liability, including any liability for negligence, for any loss, including indirect or consequential damages arising from or in relation to the use of this information sheet.
& Arts Law Centre of Australia
You may photocopy this information sheet for a non-profit purpose, provided you copy all of it, and you do not alter it in any way. Check you have the most recent version by contacting us on (02)
or tollfree outside Sydney on .
The Arts Law Centre of Australia has been assisted by the Commonwealth Government through the Australia Council, its arts funding and advisory body.
Jump (C) Les Irwig
This information sheet addresses unauthorised uses of your image, outlining that there is no specific law in Australia aimed at preventing this from happening. It suggests areas of law that may be used to try and stop an unauthorised use of your image.
David Beaumont is a Melbourne based visual artist whose works are held in private collections in Australia, the United States and the United Kingdom. He is a five time finalist in the ANL Maritime Art Prize and has exhibited in over a dozen solo exhibitions since 1999. In late 2010, he contacted Arts Law regarding an exhibition he was in the process of creating which addressed the controversial and highly emotional theme of terminal illness and euthanasia.
Arts Law often received calls from freelance photographers on the question of who owns copyright in commissioned photos. A lot of commissioners automatically assume they own copyright in the work they commission, as well as owning the negatives, but this is simply not the case.
Related sample agreements
This release protects photographers against any claim from individuals when they use photographs including those individuals.
This sample agreement is for use when a visual artist agrees to licence an existing visual image (such as a painting, a print, a drawing, a photograph or a still multimedia image) for multiple reproduction in a print or online publication.
This sample agreement should be used when a visual artist agrees to licence an existing visual image for multiple reproduction.
POPULAR RESOURCES
Can I take a photograph in public that contains images of people I don&t know? Can I take a photo of a famous landmark or of the front of someone&s house and later sell it? Read on to find out!
Copyright provides a way for artists to protect and monetise their creativity. Knowing how to license copyright and earn a royalty gives artists a way to make money from their work. This information sheet will introduce you to some of the copyright basics.
An introduction into how one can go about chasing payment that is owning to them in New South Wales. It provides clarification on the small claims procedure in NSW.
Posting or publishing written work online, whether on your personal or artist website, on& social media (including Facebook, Twitter or Pinterest) or via a blog can create a number of legal issues including copyright, defamation or trade practices. This information sheet discusses some of these issues and should be read with our information sheet entitled .
This information sheet provides an introduction into about how one can chase outstanding payment in Victoria. It provides clarification on the small claims procedure in Victoria.
This information explains the difference between a disclaimer and an exclusion clause in a contract and the circumstances when a risk warning should be used. It explains when you should use them, what they mean and the effectiveness of such clauses or statements in limit liability for injury, loss or damage. This information sheet should be read in conjunction with our .
This information sheet addresses unauthorised uses of your image, outlining that there is no specific law in Australia aimed at preventing this from happening. It suggests areas of law that may be used to try and stop an unauthorised use of your image.
This information sheet provides an introduction into about how one can chase outstanding payment in Western Australia. It provides clarification on the small claims procedure in Western Australia.
Moral rights protect the personal relationship between a creator and their work even if the creator no longer owns the work, or the copyright in the work. Moral rights concern the creator&s right to be properly attributed or credited, and the protection of their work from derogatory treatment.&
This information sheet provides an introduction into about how one can chase outstanding payment in Queensland. It provides clarification on the small claims procedure in Queensland.
View information sheets by legal topic area
View information sheets by art forms
The Arts Law Centre of Australia acknowledges the Gadigal people of the Eora Nation and all Traditional Owners of country throughout Australia.We recognise Aboriginal and Torres Strait Islander peoples' continuing connection to land, place, waters and community.We pay our respects to them, their h and to elders both past and present.
Javascript must be enabled for the correct page display
Javascript must be enabled for the correct page display
Javascript must be enabled for the correct page display
Javascript must be enabled for the correct page display

我要回帖

更多关于 汉语句子成分分析 的文章

 

随机推荐