Sponsored Content
Full Discussion: Please help on grepping
Top Forums Shell Programming and Scripting Please help on grepping Post 302214978 by joeyg on Tuesday 15th of July 2008 09:04:20 AM
Old 07-15-2008
Tools Kind of strange, but it looks like it works

The following solution (albeit not pretty) relies on substituting characters and temporarily removing new-line characters so as to facilitate the grep command. Once the grep is executed, then the data is re-expanded.


Code:
> cat logfile | sed "s/^The/~The/" | tr "\n" "+" | tr "~" "\n" | grep "return code is 1" | tr "+" "\n"
The jboss unzip return code is 1
JBOSS_HOME: /opt/coreservices/jboss-4.0.3SP1

Code:
> cat logfile | sed "s/^The/~The/" | tr "\n" "+" | tr "~" "\n" | grep "return code is 0" | tr "+" "\n"
The runLoggingInstall return code is 0
(Jul 15, 2008 2:54:33 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (startTomcatLog)
(Jul 15, 2008 2:54:35 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Wait Product Action (waitTomcatStartLog)
(Jul 15, 2008 2:55:37 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (logserver_actexec36)
(Jul 15, 2008 2:55:39 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Copy File Ex (copyfilesexdasds37)
(Jul 15, 2008 2:55:39 PM), Config, com.avaya.coreservice.icf.product.actions.CopyFileEx, msg1, CopyFileEx Config Arch : /opt/Avaya/CCR/_avpd/_arch/4.1.0/_conf.jar
(Jul 15, 2008 2:55:43 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Copy File Ex (copydhostfiles38)
(Jul 15, 2008 2:55:43 PM), Config, com.avaya.coreservice.icf.product.actions.CopyFileEx, msg1, CopyFileEx Config Arch : /opt/Avaya/CCR/_avpd/_arch/4.1.0/_conf.jar
(Jul 15, 2008 2:55:47 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (setupjboss)

The jboss chown return code is 0
(Jul 15, 2008 2:55:53 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (uninstalljboss)
(Jul 15, 2008 2:55:55 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Files (copy_usersync)
(Jul 15, 2008 2:55:56 PM), Config, com.ibm.wizard.platform.linux.LinuxProductServiceImpl, msg1, installing Exec Action (install_sync_engine

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grepping

Is there a way to grep for something and then print out 10 lines after it. for example if I want to grep for a word, then output the following 10 or whatever number of lines after the word. (5 Replies)
Discussion started by: eloquent99
5 Replies

2. UNIX for Dummies Questions & Answers

Grepping for strings

Hello. I have a dir of 1500+ dir. In these dirs is a file host, with a tag <x_tag>. I need to : 1. grep for all dir that contain this host file that contain <x_tag> 2. print a list of these host files containing <x_tag> is this better to egrep this? (5 Replies)
Discussion started by: t4st33@mac.com
5 Replies

3. Shell Programming and Scripting

grepping around

Using shell scripts, I use grep to find the word “error” in a log file: grep error this.log. How can I print or get the line 3 lines below the line that word “error” is located? Thanks in advance for your response. (9 Replies)
Discussion started by: cbeauty
9 Replies

4. Shell Programming and Scripting

Grepping issue..

I found another problem with my disk-adding script today. When looking for disks, I use grep. When I grep for the following disk sizes: 5242880 I also pick up these as well: 524288000 How do I specifically pick out one or the other, using grep, without resorting to the -v option? ... (9 Replies)
Discussion started by: LinuxRacr
9 Replies

5. UNIX for Dummies Questions & Answers

grepping columns

Hi All, I was recently helped out 'big time' with my last post on changing multiple file formats (thx, scott1256ca and bakunin)! My new question is about selecting and displaying columns in a file using (possibly) grep. Several of my data files are spreadsheet format (columns separated by... (8 Replies)
Discussion started by: ScKaSx
8 Replies

6. UNIX for Dummies Questions & Answers

grepping between files

Hi I have two files File 1 alias HOME =.. alias DATA = ${DATA}/runtime1/test alias SQL = ${DATA}/find1dir/test alias SQL1 = ${HOME}/sql/orcl alias SQL2 =... (2 Replies)
Discussion started by: ssuresh1999
2 Replies

7. Shell Programming and Scripting

grepping by digit

Hi all, Need your help here. I have a file with thousand of lines, as shown in example below KDKJAA 98324 OIDSAJ 324 KJAJAK 100 KJKAJK 89 JOIJOI 21 JDKDJL 12 UOIUOD 10 UDUYDS 8 UIUHKK 6 I would like to grep using... (5 Replies)
Discussion started by: masterpiece
5 Replies

8. UNIX for Dummies Questions & Answers

Grepping using -w and dashes (-)

I have a script to sort a list of arbitrary hosts and determine if they are supported by grepping them into a master supported list. I cut all the suffixes of the hosts in the arbitrary list, leaving the "short" hostname if you will, then grep -w them into the master list. For example: ... (1 Reply)
Discussion started by: MaindotC
1 Replies

9. Shell Programming and Scripting

Grepping more than one word

Dear Experts, Need your help. Typically we use "grep" to search and display a pattern in a txt file. However, here what we want is, we want to grep a line which contains 4 words any where in a line. For example. File has 10,000,000 lines in it out of which there is a particular line which... (1 Reply)
Discussion started by: anushree.a
1 Replies

10. Shell Programming and Scripting

Grepping and replacing

Hey Friends, Need your help again. I have input.temp file as follows $cat input.temp Lakme|Beauty Products|Lipstick L'Oreal|Hair Care|Conditioner Lakme|Beauty Products|Lip gloss L'Oreal|Hair Care|Mild Shampoo Gala|Beauty Products|Mehndi Cones Lakme|Beauty Products|Eye Shadow... (2 Replies)
Discussion started by: anushree.a
2 Replies
LOGSAVE(8)						      System Manager's Manual							LOGSAVE(8)

NAME
logsave - save the output of a command in a logfile SYNOPSIS
logsave [ -asv ] logfile cmd_prog [ ... ] DESCRIPTION
The logsave program will execute cmd_prog with the specified argument(s), and save a copy of its output to logfile. If the containing directory for logfile does not exist, logsave will accumulate the output in memory until it can be written out. A copy of the output will also be written to standard output. If cmd_prog is a single hyphen ('-'), then instead of executing a program, logsave will take its input from standard input and save it in logfile logsave is useful for saving the output of initial boot scripts until the /var partition is mounted, so the output can be written to /var/log. OPTIONS
-a This option will cause the output to be appended to logfile, instead of replacing its current contents. -s This option will cause logsave to skip writing to the log file text which is bracketed with a control-A (ASCII 001 or Start of Header) and control-B (ASCII 002 or Start of Text). This allows progress bar information to be visible to the user on the console, while not being written to the log file. -v This option will make logsave to be more verbose in its output to the user. AUTHOR
Theodore Ts'o (tytso@mit.edu) SEE ALSO
fsck(8) E2fsprogs version 1.44.1 March 2018 LOGSAVE(8)
All times are GMT -4. The time now is 02:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy