03-29-2008
The question about OS is not really well-defined. Probably uname -o is sufficient, yes. It is customary if somebody asks to include more or less all of uname -a
uname -n prints the system's name, so you don't have to use awk for that. grep is not really the right tool for this (although it could probably be done).
Generally a well-designed Unix tool will have an option to generate output in a form which is useful for scripting. Unfortunately, not nearly all system utilities are well-designed by this criterion. (ls comes to mind, and, oh, ifconfig.)
This message box is too small for a good awk tutorial (and I'm not the right person to write that) but a general pattern is awk '/text which is unique for the line you want/ { print $n }' where n is the field number (space-separated, starting from 1) on that line. There are various facilities for using something other than spaces as separators, and, well, awk is a Turing-complete programming language, so your imagination is really the only limit.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
from the man page of su:
EXAMPLES
Example 1: Becoming User bin While Retaining Your Previously
Exported Environment
To become user bin while retaining your previously exported
environment, execute:
example% su bin
Example 2: Becoming User bin and ... (4 Replies)
Discussion started by: afflack
4 Replies
2. Shell Programming and Scripting
i know this is a stupid question but...can awk do more than print? can i have it assign a value from a file list to a variable in the script? (1 Reply)
Discussion started by: MadHatter
1 Replies
3. UNIX for Dummies Questions & Answers
i have a file that contain lines like this
9.4.7.8.5.7.9.0.5.7.1.2.msisdn.sub.cs. 1 IN CNAME SDP01.cs.
there are about 50,000 lines like this in the files i want to the extract the digits from the above line like:-
947857905712
OS Solaris9 (3 Replies)
Discussion started by: muneebr
3 Replies
4. Shell Programming and Scripting
Hi, pls advise how could we merge contents of lines from 2 different files into 1 file but shares common label continously as in the following example:
Thanks in advance...rgds.
File1:
// line: 0
abc
def
// line: 1
ghi
jkl
File2:
// line: 0
mno
pqr
// line: 1
stu
vwx
End... (3 Replies)
Discussion started by: Manan
3 Replies
5. Solaris
Hi,,,,,
My question is :
i have to backup a file system of size 92 GB
/dev/dsk/c1t1d0s2 135G 92G 41G 70% /data
i use the command :
ufsdump 0cfu /backup/c1t1d0s2 /dev/rdsk/c1t1d0s2 ......
the output file of the backup is only 2 GB it's normal ?? or i have do a... (0 Replies)
Discussion started by: tt155
0 Replies
6. Shell Programming and Scripting
Hi
how can I know the details of when valid system users last logged on?
thanks (1 Reply)
Discussion started by: nokia1100
1 Replies
7. Shell Programming and Scripting
Hi,
I'm a oracle DBA with little knowledge of Unix.
I wanted to write some shell scripts which will be helpful for DBA's regular activity.
As i'm a new to oracle with unix can any plese tell me what are all the activities can be done throgh Unix Shell Scripts also suggest me how to learn... (1 Reply)
Discussion started by: msgobinathan
1 Replies
8. Forum Support Area for Unregistered Users & Account Problems
I hadn't logged on here in several months. I want to update my info, such as the email address that I can be contacted at, but I don't see any links to do that. (1 Reply)
Discussion started by: cleopard
1 Replies
9. Shell Programming and Scripting
I have this working ksh, and it returns like below:
LOGICAL VOLUME: prod_2048_005 VOLUME GROUP: prod1vg
TYPE: raw WRITE VERIFY: off
PHYSICAL VOLUME: hdisk108 VOLUME GROUP: prod1vg
TOTAL PPs: 1023 (130944 megabytes) VG DESCRIPTORS: 1
USED PPs: 904 (115712 megabytes) MAX REQUEST: 1 megabyte... (1 Reply)
Discussion started by: Daniel Gate
1 Replies
10. UNIX for Advanced & Expert Users
I need to find a way to query the OS (on Linux or Unix) to get details about the host machines processor type and the primary hard drive serial number. Is this possible?
Thank you for any Guru help you can provide! (2 Replies)
Discussion started by: Pug
2 Replies
UNAME(1) General Commands Manual UNAME(1)
NAME
uname - display information about the system
SYNOPSIS
uname [-amnrsv]
DESCRIPTION
The uname command writes the name of the operating system implementation to standard output. When options are specified, strings repre-
senting one or more system characteristics are written to standard output.
The options are as follows:
-a Behave as though the options -m, -n, -r , -s, and -v were specified.
-m Write the type of the current hardware platform to standard output.
-n Write the name of the system to standard output.
-r Write the current release level of the operating system to standard output.
-s Write the name of the operating system implementation to standard output.
-v Write the version level of this release of the operating system to standard output.
If the -a flag is specified, or multiple flags are specified, all output is written on a single line, separated by spaces.
The uname utility exits 0 on success, and >0 if an error occurs.
SEE ALSO
sysctl(8), sysctl(3), uname(3)
HISTORY
The uname command appeared in 4.4BSD.
STANDARDS
The command is expected to conform to the IEEE Std1003.2 (``POSIX'') specification.
4th Berkeley Distribution February 4, 1995 UNAME(1)