Sponsored Content
Top Forums Shell Programming and Scripting Assistance to use ls and GREP Post 302559545 by cdc01 on Tuesday 27th of September 2011 11:03:47 AM
Old 09-27-2011
[solved] Assistance to use ls and GREP

Hi

We have several folders and subfolders in a heirarchy, representing clients and files we send to them. Files that are not processed are placed in reject folder. I am able to run a LS that will scan all these folders, and ones that show entries (rejected files) are seen here. I am looking for a way ( | grep perhaps) that will only show the folder structures that have contents.

Here is my LS command:
Code:
ls -l BU/AD_*/ANTS*/SERVER/REJECT
I then get a list (there are like 200 clients) that looks like this:
 
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
BU/BACAR/TASRO0034/SERVER/REJECT:
total 0
 
BU/BACAR/TASRO0048/SERVER/REJECT:
total 0
 
BU/BACAR/TASRO0109/SERVER/REJECT:
total 0
 
BU/BACAR/TASRO0110/SERVER/REJECT:
total 0
 
BU/BACAR/TASRO0111/SERVER/REJECT:
total 0
 
BU/BAFINANCE/TASRO0005/SERVER/REJECT:
total 0
 
BU/BAFINANCE/TASRO0006/SERVER/REJECT:
total 0
 
BU/BAFINANCE/TASRO0038/SERVER/REJECT:
total 0
 
BU/BAFINANCE/TASRO0050/SERVER/REJECT:
total 0
 
BU/BAFINANCE/TASRO0051/SERVER/REJECT:
total 96
-rw-r-----    1 xxxxxx xxxxxx          201 Aug 02 12:55 
testfile.asdasd 20110802_125518
-rw-r-----    1 xxxxxx xxxxxx         201 Aug 20 03:06 testfile.asdasd.20110820_030619
-rw-r-----    1 xxxxxx xxxxxx          5628 Aug 02 12:55 aircancr.points.20110802_125538
-rw-r-----    1 xxxxxx xxxxxx         3819 Aug 19 01:44 testfile.asdasd.20110819_014423
 
<<<<<<<<<<<<<<<<<
<<<<<<<<<<<<<<<<<

So i am looking for a way (| GREP or other at the end of the ls) to omit the folders that have no entries.

I have attempted to do
Code:
ls -l BU/AD_*/ANTS*/SERVER/REJECT | grep "!TOTAL 0"

but this doesnt work


Thanks for your time

Last edited by vbe; 09-27-2011 at 12:21 PM.. Reason: please use code tags next time
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need Assistance

I have two questions I am struggling with... How do the programs p1, p2, and p3 need to handle their standard files so they can work like this: p1 | p2 | p3 ? What exactly is this command supposed to do? $ kill -QUIT %1 & This command below? $ sort -o emp.lst emp lst & Any... (1 Reply)
Discussion started by: yahoo14
1 Replies

2. Shell Programming and Scripting

I need an assistance

I have a school project to create a shell program same as calendar i must create a txt file with celebrations with vi i know this but the problem is i don't know awk and grep. The object of object is to create a program who read a date an appear the celebration. Can you help me please !!!... (1 Reply)
Discussion started by: mytilini boy
1 Replies

3. UNIX for Dummies Questions & Answers

While Loop assistance.

I am trying to make a simple while loop which reads in a text until the person types quit. And it's not working, and I know it's a rather simple problem I just can't seem to understand... Once again all assistance is greatly appreciated. #!/bin/sh astring="z" while astring!="quit" do read... (2 Replies)
Discussion started by: MaestroRage
2 Replies

4. Shell Programming and Scripting

Awk Assistance

Hello A friend of mine posted this on another site that I follow. It is to advanced for me to figure out. If solved I will give credit where credit is due: NOTE: Does not have to be AWK. Any Language will work, Hi. I need a little assistant to write an awk script on linux that reads a file... (12 Replies)
Discussion started by: abacus
12 Replies

5. Shell Programming and Scripting

Grep Alerting - command or script assistance

Hello! I need some help with grep from various logs we use for monitoring transactions. The logs contain the following information (which is consistent in all of the files): 12:28:33.157 EWY D 1 (tcpip.c:282): tcpip.c: Unable to connect to x.x.x.x on port xxxx. (79) Connection refused ... (1 Reply)
Discussion started by: sbchecko
1 Replies

6. UNIX for Dummies Questions & Answers

Crontab assistance

I have a script that runs a SQL query and then emails me the results. It runs correctly alone. I am trying to set up a cron that will run the script every day at say 5:00. When the script runs alone, the results are emailed exactly like I want the, but when I set up a cronjob, I get a blank email.... (7 Replies)
Discussion started by: alpinescott
7 Replies

7. Shell Programming and Scripting

Need assistance with sed

Hi All, I need your assistance, I would like to replace all lines beginning with the word "begin" with the below text: Device | IPMB0-A | IPMB0-B Board Address |Sent SentErr %Errr |Sent SentErr ... (9 Replies)
Discussion started by: Dendany83
9 Replies

8. Homework & Coursework Questions

Grep expressions homework, need assistance

Please dont delete, im listing my assignment and will be editing as i work on it. I am NOT looking for answers but help in understanding how to use grep 1. The problem statement, all variables and given/known data: For each question, list the command lines used in addition to any other details... (3 Replies)
Discussion started by: alindner
3 Replies

9. AIX

AIX 3.2.5 Assistance

I am looking for any help on locating a set of install disks or downloads of AIX 3.2.5 or earlier.. We recently lost our HDD running AIX 3.2.5 and need to reinstall but have no OS disk to complete.. Any help would be appreciated.. Thanks (4 Replies)
Discussion started by: rmsdp
4 Replies

10. UNIX for Beginners Questions & Answers

Student needs grep command assistance

I am a student in a UNIX/Linux classes having hard time with grep looking for assistance on some home work I need to figure out some kind of grep command to get a out put that only gives me information from a sample file and only list the people with the first name John the sample file is named... (1 Reply)
Discussion started by: jetoutant
1 Replies
GZGREP(1)						      General Commands Manual							 GZGREP(1)

NAME
gzgrep, gzegrep, gzfgrep - search possibly compressed files for a regular expression SYNOPSIS
gzgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
gzgrep is used to invoke the grep on compress'ed or gzip'ed files. All options specified are passed directly to grep. If no file is speci- fied, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If gzgrep is invoked as gzegrep or gzfgrep then egrep or fgrep is used instead of grep. If the GREP environment variable is set, gzgrep uses it as the grep program to be invoked. For example: for sh: GREP=fgrep gzgrep string files for csh: (setenv GREP fgrep; gzgrep string files) AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), egrep(1), fgrep(1), gzdiff(1), gzmore(1), gznew(1), gzforce(1), gzip(1), gzexe(1) ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWgzip | +--------------------+-----------------+ |Interface Stability | External | +--------------------+-----------------+ NOTES
Source for gzip is available in the SUNWgzipS package. GZGREP(1)
All times are GMT -4. The time now is 06:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy