i noticed one error when i tried the solution for the following input:
read.txt contains:
Actual output:
Expected output:
with rdcwayx solution,actual ouput i got as follows:
i understood pravin27 logic. i didn't get the logic of using negation!Is it not something similar to grep -v?
---------- Post updated at 07:03 AM ---------- Previous update was at 06:11 AM ----------
i think i fixed it as follows:
Last edited by dragon.1431; 09-24-2010 at 09:04 AM..
Reason: added the new solution
Hi, guys. I have one question:
I need to search for a string in a file, and then extract another string from the file and assign it to a variable.
For example:
the contents of the file (group) is below:
...
ftp:x:23:
mail:x:34
...
testing:x:2001
sales:x:2002
development:x:2003
...... (6 Replies)
Hi
I want to read a file line by line and search for a particular string in each line(say for example string containing @ )and save that string into a variable.
Can someone suggest me the way to implement it.I am using K- shell
Thanks
Ishita (5 Replies)
Hi,
i call my shell like:
my_shell "my project name"
my script:
#!/bin/bash -vx
projectname=$1
sed s/'PROJECT_NAME ='/'PROJECT_NAME = '$projectname/ <test_config_doxy >temp
cp temp test_config_doxy
the following error occurres:
sed s/'PROJECT_NAME ... (2 Replies)
Guys I am having trouble trying to pull some data from a file using a value returned from a for statement. Any help would greatly be apprecaited. I can't seem to get my script to pass the variable. I am trying to pull the 2 lines below the line that has the "pool name" so that i can get the... (5 Replies)
Can someone tell me how I can do this?
e.g:
a=$(echo -e wert trewt ertert ertert ertert erttert
erterte
rterter
tertertert
ert)
How do i replace the STRING with $a?
I try this:
sed -i 's/STRING/'"$a"'/g' filename.ext
but this don' t work (2 Replies)
Hi ,
I have input file like below
Hi this is "vinoth".
Hi happy to work with 'unix'
USA(united states of America)
My script variables are below :
Dquote=Ộ
Squote=&#$567
Obrac=&^986
Cbrac=&^745
I want to read the variables in my SED command to replace the double quote,single... (9 Replies)
Hi,
I am trying to find a way to get sed/awk/grep to help me find a string in a log file that exists between two datestamps and then print the preceding datestamp up to the next datestamp.
Here is an example of my logfile:
+++ 2013/03/28 17:01:37.085 SIGNALING HIGH ACTIVE
Failure Response... (5 Replies)
Hi !
I want to search a string in all lines with sed. If that string is there, i want to look for an other string in the next line.If that string is there i want to put an other line under it.
eg:
aaa
bbb
ccc
ddd
cat bla.txt | sed -e '/aaa/a\' -e ' \!!!'
in the upper case, i would... (6 Replies)
Dear all,
I try to replace a string of characters in a file (MyFile.txt) by a multiline value of the variable "Myvar":
$ cat MyFile.txt
DESCRIPTION '@TargetTable SCHEMA'
(
@InputFlowDef
);
$
The content of Myvar:
$ echo "$Myvar"
col1
, col2
, col3
$ (4 Replies)
I'm interested to match column pattern through awk using an external variable for data:
-9 1:751343:T:A -9 0 T A 0.726 -5.408837e-03 9.576603e-03 7.967536e-01 5.722312e-01
-9 1:751756:T:C -9 0 T C 0.727 -5.360458e-03 9.579447e-03 7.966977e-01 5.757858e-01... (7 Replies)
Discussion started by: genome
7 Replies
LEARN ABOUT SUNOS
runuser
RUNUSER(1) User Commands RUNUSER(1)NAME
runuser - run a command with substitute user and group ID
SYNOPSIS
runuser [options] -u user [[--] command [argument...]]
runuser [options] [-] [user [argument...]]
DESCRIPTION
runuser allows to run commands with a substitute user and group ID. If the option -u is not given, it falls back to su-compatible seman-
tics and a shell is executed. The difference between the commands runuser and su is that runuser does not ask for a password (because it
may be executed by the root user only) and it uses a different PAM configuration. The command runuser does not have to be installed with
set-user-ID permissions.
If the PAM session is not required then recommended solution is to use setpriv(1) command.
When called without arguments, runuser defaults to running an interactive shell as root.
For backward compatibility, runuser defaults to not change the current directory and to only set the environment variables HOME and SHELL
(plus USER and LOGNAME if the target user is not root). This version of runuser uses PAM for session management.
OPTIONS -c, --command=command
Pass command to the shell with the -c option.
-f, --fast
Pass -f to the shell, which may or may not be useful depending on the shell.
-g, --group=group
The primary group to be used. This option is allowed for the root user only.
-G, --supp-group=group
Specify a supplemental group. This option is available to the root user only. The first specified supplementary group is also used
as a primary group if the option --group is unspecified.
-, -l, --login
Start the shell as a login shell with an environment similar to a real login:
o clears all the environment variables except for TERM
o initializes the environment variables HOME, SHELL, USER, LOGNAME, PATH
o changes to the target user's home directory
o sets argv[0] of the shell to '-' in order to make the shell a login shell
-m, -p, --preserve-environment
Preserve the entire environment, i.e. it does not set HOME, SHELL, USER nor LOGNAME. The option is ignored if the option --login is
specified.
-s, --shell=shell
Run the specified shell instead of the default. The shell to run is selected according to the following rules, in order:
o the shell specified with --shell
o the shell specified in the environment variable SHELL if the --preserve-environment option is used
o the shell listed in the passwd entry of the target user
o /bin/sh
If the target user has a restricted shell (i.e. not listed in /etc/shells) the --shell option and the SHELL environment variables
are ignored unless the calling user is root.
--session-command=command
Same as -c , but do not create a new session. (Discouraged.)
-V, --version
Display version information and exit.
-h, --help
Display help text and exit.
CONFIG FILES
runuser reads the /etc/default/runuser and /etc/login.defs configuration files. The following configuration items are relevant for
runuser:
ENV_PATH (string)
Defines the PATH environment variable for a regular user. The default value is /usr/local/bin:/bin:/usr/bin.
ENV_ROOTPATH (string)
ENV_SUPATH (string)
Defines the PATH environment variable for root. The default value is /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin.
ALWAYS_SET_PATH (boolean)
If set to yes and --login and --preserve-environment were not specified runuser initializes PATH.
EXIT STATUS
runuser normally returns the exit status of the command it executed. If the command was killed by a signal, runuser returns the number of
the signal plus 128.
Exit status generated by runuser itself:
1 Generic error before executing the requested command
126 The requested command could not be executed
127 The requested command was not found
FILES
/etc/pam.d/runuser
default PAM configuration file
/etc/pam.d/runuser-l
PAM configuration file if --login is specified
/etc/default/runuser
runuser specific logindef config file
/etc/login.defs global logindef config file
SEE ALSO setpriv(1), su(1), login.defs(5), shells(5), pam(8)HISTORY
This runuser command was derived from coreutils' su, which was based on an implementation by David MacKenzie, and the Fedora runuser com-
mand by Dan Walsh.
AVAILABILITY
The runuser command is part of the util-linux package and is available from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils
/util-linux/>.
util-linux July 2014 RUNUSER(1)