Sponsored Content
Top Forums Shell Programming and Scripting Please review script for search in all files Post 302367834 by bkeep on Tuesday 3rd of November 2009 03:09:21 PM
Old 11-03-2009
Thanks for the info.

I made a small change.
Broken after pipe to reduce screen scrolling.
Code:
grep -InE $LOOKFOR $i/public_html/* -R |
awk -F: 'NR==1{print $1,"\n" $2,$3; next} p!=$1{p=$1; print p} {print "   " $2,$3}'

I get output like this
Code:
/home/openauto/public_html/wiki/lib/tpl/default/main.php
   34   <?php /*old includehook*/ @include(dirname(__FILE__).'/meta.html')?>
   38 <?php /*old includehook*/ @include(dirname(__FILE__).'/topheader.html')?>
   55     <?php /*old includehook*/ @include(dirname(__FILE__).'/header.html')?>
/home/openauto/public_html/wiki/lib/tpl/sidebar/main.php
   36   <?php /*old includehook*/ @include(dirname(__FILE__).'/meta.html')?>
   40 <?php /*old includehook*/ @include(dirname(__FILE__).'/topheader.html')?>
   60     <?php /*old includehook*/ @include(dirname(__FILE__).'/header.html')?>

Is there an easy way to get consistent column widths for fields $2 $3?

Something like this is what I am after, The $3 has a variable length of whitespace and tabs that I would like to remove if at all possible, then add something like 4 spaces back in front.
Code:
/home/openauto/public_html/wiki/lib/tpl/default/main.php
   34    <?php /*old includehook*/ @include(dirname(__FILE__).'/meta.html')?>
   38    <?php /*old includehook*/ @include(dirname(__FILE__).'/topheader.html')?>
   55    <?php /*old includehook*/ @include(dirname(__FILE__).'/header.html')?>
/home/openauto/public_html/wiki/lib/tpl/sidebar/main.php
   36    <?php /*old includehook*/ @include(dirname(__FILE__).'/meta.html')?>
   40    <?php /*old includehook*/ @include(dirname(__FILE__).'/topheader.html')?>
   123   <?php /*old includehook*/ @include(dirname(__FILE__).'/header.html')?>

Thanks again for the help.
Regards,
Brandon
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Review the Shell Script

Hi, I want to copy all the log file except current date log from one server to another server. Log File will be like this LOGNIG_08_11_2008*.log For this cd /test/log date -d '1 day ago' "+%d_%m_%Y" -->This command gives previous day scp LOGSNIG_date -d '1 day ago' "+%d_%m_%Y"... (2 Replies)
Discussion started by: srinivasvandana
2 Replies

2. Shell Programming and Scripting

Please, review script.

Hi guys, I 've been brewing this shellscript, but I can't test it until next tuesday. In the meantime I am too curious wether it will work or not, so I'd like to hear your comments. Background: I want to watch the user quota for mailboxes in various email-domains on a IMAP-server. I have... (1 Reply)
Discussion started by: algernonz
1 Replies

3. Shell Programming and Scripting

Review Check list for Unix Shell Script

Hi, I need Unix Shell Script Review Check list in the format of word or excel. Can any one provide the review checklist for unix shell script. Pls. (1 Reply)
Discussion started by: praka
1 Replies

4. Shell Programming and Scripting

a shell script for review.

I have written a bit of shell that lets our company check all our SSL certs. the aim is to have a list of servers and run this check from cron once a week. Our managers have decided that we will not run BASH, so it has been written in /bin/sh and only needs openssl, no perl, no bash, no extra... (8 Replies)
Discussion started by: robsonde
8 Replies

5. Shell Programming and Scripting

shell script to search and copy files

Hello Im new to this forums, I would like some help regarding a script that I need in order to copy some files. Heres the scenario: I need to search several files which have a particular code inside, lets say "test" all of them on different directories. I need to copy all of them on a new... (4 Replies)
Discussion started by: c.watson
4 Replies

6. UNIX for Dummies Questions & Answers

Script to search and copy files

HI everyone, I been to this site before for help and found my answers on other threads now I am posting my own :). I have a list of file names with out extensions on an txt file. I need a way for the script to search on the server for each file name and copy the files over to a new directory.... (12 Replies)
Discussion started by: sergiol
12 Replies

7. Shell Programming and Scripting

Please review error routines in my ksh script

The script distributes files from an AIX server using iether ftp or sftp depending on the constraint of the destination server. I am interested in having the error checking routine critically reviewed. I will only include an excerpt from the script concerning error trapping: (where $FTP_OUT is the... (7 Replies)
Discussion started by: peleton
7 Replies

8. Shell Programming and Scripting

Peer Review File/Folder Script

Hello *nix friends, I've written a shell script that allow web admin's to copy file/folder from a development site to the production site. It's more or less a poor man SVN. I'm posting the script here because I was able to get many questions answered through this forum and also, I want to... (4 Replies)
Discussion started by: rwhite35
4 Replies
ERROREXCEPTION(3)							 1							 ERROREXCEPTION(3)

ErrorException

INTRODUCTION
An Error Exception. CLASS SYNOPSIS
ErrorException ErrorExceptionextends Exception Properties o protected int$severity Inherited properties o protected string$message o protected int$code o protected string$file o protected int$line Methods o public ErrorException::__construct NULL ([string $message = ""], [int $code], [int $severity = 1], [string $filename = __FILE__], [int $lineno = __LINE__], [Exception $previous]) o finalpublic int ErrorException::getSeverity (void ) Inherited methods o finalpublic string Exception::getMessage (void ) o finalpublic Exception Exception::getPrevious (void ) o finalpublic mixed Exception::getCode (void ) o finalpublic string Exception::getFile (void ) o finalpublic int Exception::getLine (void ) o finalpublic array Exception::getTrace (void ) o finalpublic string Exception::getTraceAsString (void ) o public string Exception::__toString (void ) o finalprivate void Exception::__clone (void ) PROPERTIES
o $severity -The severity of the exception EXAMPLES
Example #1 Use set_error_handler(3) to change error messages into ErrorException. <?php function exception_error_handler($severity, $message, $file, $line) { if (!(error_reporting() & $severity)) { // This error code is not included in error_reporting return; } throw new ErrorException($message, 0, $severity, $file, $line); } set_error_handler("exception_error_handler"); /* Trigger exception */ strpos(); ?> The above example will output something similar to: Fatal error: Uncaught exception 'ErrorException' with message 'strpos() expects at least 2 parameters, 0 given' in /home/bjori/tmp/ex.php:12 Stack trace: #0 [internal function]: exception_error_handler(2, 'strpos() expect...', '/home/bjori/php...', 12, Array) #1 /home/bjori/php/cleandocs/test.php(12): strpos() #2 {main} thrown in /home/bjori/tmp/ex.php on line 12 PHP Documentation Group ERROREXCEPTION(3)
All times are GMT -4. The time now is 06:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy