Saying, I have two distinct functions with the same goal (counting lines containing a specific pattern in a file MyFile).
To perform that operation, I used a "while loop" with two different syntax ("grep" command would be much more better in that case but this is not the concern in our case) !:
(1) cat MyFile | while read -r line;do; ... ;done;
(2) while read -r line; do; ...;done < MyFile;
Inside the while loop, I used a variable var to store the result.
My questions:
(1) is that the expected behaviour to not be able to get the value of var outside the while for the first syntax ?
(2) what kind of system's difference between both syntax ?
okay, this shouldn't be difficult but I can't figure it out. How can I set a variable with another variable. I have the following:
foreach pe ($dir $sp)
set tpe = `echo $pe | grep M`
if ($tpe == M) then
set ${$pe} = M <--- This doesn't work
else
endif
end
In this case what... (2 Replies)
#!/bin/sh
APP_ROOT_MODE1=/opt/app1.0
APP_ROOT_MODE2=/opt/app2.0
APP_ROOT=${APP_ROOT_${APP_MODE}}
# enviornment variable APP_MODE will be exported in the terminal where
# we run the applciation, its value is string - MODE1 or MODE2
# My intension is:
# when export APP_MODE=MODE1... (4 Replies)
I am writing a script to cross check the dbscript. For that I am searching the SQL manipulators in the dbscript as shown below. But my problem is the variable $pattern is coming as null when comes out of the foreach loop.
File content:
=========
vi /home2/niroj_p/dbscript.sql
-------... (1 Reply)
Dear All,
we have a command output which looks like :
Total 200 queues in 30000 Kbytes
and we're going to get "200" and "30000" for further process. currently, i'm using :
numA=echo $OUTPUT | awk '{print $2}'
numB=echo $OUTPUT | awk '{print $5}'
my question is : can I use just one... (4 Replies)
How can I assign a variable to an variable. IE $car=honda
One way I can do it is export $car=honda
or
let $car=2323
Is there any other ways to preform this task (3 Replies)
Hi,
I am trying to do the following thing
var='date'
$var
Above command substitutes date for and in turn runs the date command and i am getting the todays date value.
I am trying to do the same thing as following, but facing some problems,
unique_host_pro="sed -e ' /#/d'... (3 Replies)
Simple enough problem I think, I just can't seem to get it right.
The below doesn't work as intended, it's just a function defined in a much larger script:
CheckValues() {
for field in \
Group_ID \
Group_Title \
Rule_ID \
Rule_Severity \
... (2 Replies)
Hi,
I have Below script which converts csv file to html succesfully.but the visiblity is simple in black n white. I want to have better visibilty of each columns in different colours(like green).As it is a Database report suppose some tablespace available space is less than 20% then it should... (7 Replies)
Does anyone know if it is possible to check whether a window in x11 (using xlib) is visible or not? I tried XGetWindowProperty, but that doesn't work, because the windows host (dtwm on Solaris 10) does not support EWMH. (5 Replies)
I have the following script, and I want to assign the output ($10 and $5) from awk to N and L:
grdinfo data.grd | awk '{print $10,$5}'| read N L
output from gridinfo data.grd is: data.grd 50 100 41 82 -2796 6944 0.016 0.016 3001 2461. where N and L is suppose to be 3001 and 100. I use... (8 Replies)
Discussion started by: geomarine
8 Replies
LEARN ABOUT NETBSD
who
WHO(1) BSD General Commands Manual WHO(1)NAME
who -- display who is logged in
SYNOPSIS
who [-abdHlmqrstTuv] [file]
who am i
DESCRIPTION
The who utility displays a list of all users currently logged on, showing for each user the login name, tty name, the date and time of login,
and hostname if not local.
Available options:
-a Same as --bdlprTtuv.
-b Time of last system boot.
-d Print dead processes.
-H Write column headings above the regular output.
-l Print system login processes.
-m Only print information about the current terminal. This is the POSIX way of saying who am i.
-p Print active processes spawned by init(8).
-q ``Quick mode'': List only the names and the number of users currently logged on. When this option is used, all other options are
ignored.
-r Print the current runlevel. Supported runlevels are:
d (DEATH) The system has halted.
s (SINGLE_USER) The system is running in single user mode.
r (RUNCOM) The system is executing /etc/rc.
t (READ_TTYS) The system is processing /etc/ttys.
m (MULTI_USER) The system is running in multi-user mode.
T (CLEAN_TTYS) The system is in the process of stopping processes associated with terminal devices.
c (CATATONIA) The system is in the process of shutting down and will not create new processes.
-s List only the name, line and time fields. This is the default.
-T Print a character after the user name indicating the state of the terminal line: '+' if the terminal is writable; '-' if it is not; and
'?' if a bad line is encountered.
-t Print last system clock change.
-u Print the idle time for each user, and the associated process ID.
-v When printing of more information is requested with -u, this switch can be used to also printed process termination signals, process
exit status, session id for windowing and the type of the entry, see documentation of ut_type in getutxent(3).
am I Returns the invoker's real user name.
file By default, who gathers information from the file /var/run/utmpx. An alternative file may be specified which is usually /var/log/wtmpx
(or /var/log/wtmp, or /var/log/wtmpx.[0-6] or /var/log/wtmp.[0-6] depending on site policy as wtmpx can grow quite large and daily ver-
sions may or may not be kept around after compression by ac(8)). The wtmpx and wtmp file contains a record of every login, logout,
crash, shutdown and date change since wtmpx and wtmp were last truncated or created.
If /var/log/wtmpx or /var/log/wtmp are being used as the file, the user name may be empty or one of the special characters '|', '}' and '~'.
Logouts produce an output line without any user name. For more information on the special characters, see utmp(5).
FILES
/var/run/utmp
/var/run/utmpx
/var/log/wtmp
/var/log/wtmp.[0-6]
/var/log/wtmpx
/var/log/wtmpx.[0-6]
SEE ALSO last(1), mesg(1), users(1), getuid(2), utmp(5), utmpx(5)STANDARDS
The who utility is expected to conform to IEEE Std 1003.2-1992 (``POSIX.2'').
HISTORY
A who utility appeared in Version 6 AT&T UNIX.
BSD January 17, 2007 BSD