Sponsored Content
Full Discussion: combine two greps
Top Forums UNIX for Dummies Questions & Answers combine two greps Post 302548781 by shifahim on Friday 19th of August 2011 10:00:29 AM
Old 08-19-2011
Question

As i said i do not know much about this.

Below is what i did.

Does not look like i have privileges or do i ?
Code:
cd

pwd
/home/wlsuser

ls -ltr .profile
-rw-------   1 wlsuser root          25 Oct 20  2009 .profile

id
uid=870(wlsuser) gid=641(wlsgrp)

groups wlsuser
wlsgrp webgrp webgroup ndm wlsuser httpd

Can you please help me with the detailed steps ?

---------- Post updated at 08:19 AM ---------- Previous update was at 08:15 AM ----------

Quote:
no - you can not use su without a password unless your root. For what your are doing root is not required. If it was you could use sudo.
Thats not a problem. I am providing the password as well. Setting this automatically is my concern.

---------- Post updated at 09:00 AM ---------- Previous update was at 08:19 AM ----------

Quote:
Originally Posted by yazu
Well... Yes. But it's better use some more descriptive names (usually in uppercase) and export them. Add something like this in your profile:
Code:
APACHE_N=`...`
export APACHE_N

But these values will be constant. Maybe it's better to use aliases:
Code:
alias ca='/usr/bin/svcs -a |grep apache22 | wc -l'
alias pw='ps -ef | grep wls[a]dmin | grep -v "grep" | wc -l'

Then:
Code:
echo $((`ca`+`pw`))

It will work only on the command line not in scripts.
echo $pw
return blank

while

Code:
 echo $((`ca`+`pw`))
bash: ./1: Permission denied
bash: 51: command not found
bash: +: syntax error: operand expected (error token is "+")

I am on bash and

Code:
uname -a
SunOS mymachine 5.10 Generic_144488-07 sun4v sparc SUNW,SPARC-Enterprise-T5220

Yes, I need the value to change dynamically and not be constant as some processes might get killed post su - wlsuser
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combine new files

Hi All , Any one help me to combine two files in shell scripting .Below is my requrement i have 2 files as follows filea newyork America Texas America london Engalad Fileb abc def xyz i have to combine this file as follows newyork America abc Texas ... (1 Reply)
Discussion started by: ajmalc
1 Replies

2. UNIX for Dummies Questions & Answers

Combine commands

Hi, i tried to combine grep with find and it didnt work grep 'find dirname filename" i also would like that the file will be sorted in the way. thanks a lot. (2 Replies)
Discussion started by: Spoiler
2 Replies

3. UNIX for Dummies Questions & Answers

Command that creates file and also greps that file?

I have a command that does something and then creates a log file (importlog.xml). I then want to grep that newly created log (importlog.xml) file for a certain word (success). I then want to write that grep result to a new file (success.log). So far I can run the command which creates the... (2 Replies)
Discussion started by: Sepia
2 Replies

4. Shell Programming and Scripting

combine

Hi I am having text file like this 001|ramu|hno221|>< sheshadripuram|delhi|560061>< 002|krishna|hno225|>< newdelhimain|delhi|560061>< i want to combine every two lines as single...line... i.e 001|ramu|hno221|sheshadripuram|delhi|560061 can u pls help me (3 Replies)
Discussion started by: suryanarayana
3 Replies

5. Shell Programming and Scripting

combine

Dear all i am having text file like xxx|yyy|1|2| zzz|rrr|3|4| www|xxx|>< 5|6|>< jjj|kkk|>< 8|9>< i want to join two lines which are having ' >< ' by taking only two lines at a stretch ...using awk command the result output should be xxx|yyy|1|2| zzz|rrr|3|4| www|xxx|5|6|... (2 Replies)
Discussion started by: suryanarayana
2 Replies

6. Shell Programming and Scripting

help with a shell script that greps an error from the logs

Hello everyone. I wrote the following script but the second part is not excecuting. It is not sending the notification by email if the error occurs. the send mail is working so i think the errorr should be in the if statement LOGDIR=/logs/out LOG=`date "+%Y%m%d"`.LOG-FILE.out #the log file ... (11 Replies)
Discussion started by: adak2010
11 Replies

7. UNIX for Dummies Questions & Answers

Struggling to combine two Greps statements

Greetings! I have been tasked to create a report off files we receive from our hardware suppliers. I need to grep these files for two fields 'Test_Version' and 'Model-Manufacturer' ; for each field, I need to capture their corresponding values. When running each statement separately, I get... (4 Replies)
Discussion started by: alan
4 Replies

8. Shell Programming and Scripting

Script Optimization - large delimited file, for loop with many greps

Since there are approximately 75K gsfiles and hundreds of stfiles per gsfile, this script can take hours. How can I rewrite this script, so that it's much faster? I'm not as familiar with perl but I'm open to all suggestions. ls file.list>$split for gsfile in `cat $split`; do csplit... (17 Replies)
Discussion started by: verge
17 Replies

9. Shell Programming and Scripting

Bash Scipting (New); Run multiple greps > multiple files

Hi everyone, I'm new to the forums, as you can probably tell... I'm also pretty new to scripting and writing any type of code. I needed to know exactly how I can grep for multiple strings, in files located in one directory, but I need each string to output to a separate file. So I'd... (19 Replies)
Discussion started by: LDHB2012
19 Replies

10. UNIX for Beginners Questions & Answers

Combining multiple greps

I'm trying to learn about regular expressions. Let's say I want to list all the files in /usr/bin beginning with "p", ending with "x", and containing an "a". I know this works:ls | grep ^p | grep x$ | grep abut I'm thinking there must be a way to do it without typing grep three times. Some of my... (9 Replies)
Discussion started by: Xubuntu56
9 Replies
All times are GMT -4. The time now is 11:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy