AWK help print dirs with files in it


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting AWK help print dirs with files in it
# 1  
Old 09-07-2011
AWK help print dirs with files in it

Hi,

I'm writing some start of day checks for my work. I want to check some dirs for files that have been created longer than 10 mins ago and not been transfered. I've already used a find command to write a list of files that meet this criteria to a log called sod.log
i.e.
Code:
/filetransfer/dir1/outgoing/B84743
/filetransfer/dir2/outgoing/B84743
/filetransfer/dir3/outgoing/B84743

I'm now updating the script that writes the output to the screen if such files exist.

I thought something like this would work but It does not seem to
Code:
for outgo in dir1 dir2 dir3 dir4
do
awk '/outgoing/ && /'"$outgo"'/ {print $0} sod.log || grep -q "$outgo" || print file in outgoing dir $outgo please check.

Any help would be appreciated.

Thanks
Phil.

Last edited by Franklin52; 09-08-2011 at 08:06 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 09-08-2011
I'm not sure what out you want or what your requirements are. Kinda vague.

This does what you seem to want
Code:
find /filetransfer/dir*/outgoing -mmin +10 |
while read fname
do
     echo "Please check file in outgoing directory: $(dirname $(dirname $fname)) "
done > sort -u

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace a string in files in all dir and sub dirs

Hello, I need to replace xml version='1.1' with xml version='1.0' in all xml files under /app/jenkins/ in all dir and sub dirs in my CentOS VM, I tried below command but it didn't help, looks like I'm missing a character somewhere. grep -rl "xml version='1.1'" . | xargs sed -i 's/"xml... (2 Replies)
Discussion started by: mahesh Madpathi
2 Replies

2. Shell Programming and Scripting

Moving files into dirs corresponding to dates

I am trying to find a way to move files into corresponding date files. i=0 while read line do array="$line" (( i++ )) done < <(ls) cd $(echo ${array}) echo ${array}} pwd #cd "$(array}" ] || mkdir 2015 cd "2015" ] || mkdir 02-February ] || mkdir 03-March ] || mkdir... (10 Replies)
Discussion started by: newbie2010
10 Replies

3. Debian

Problem with files/dirs deletion

Hi, The other day i installed a PHP based CMS (modx) on my shell account and noticed that i couldn't delete any of files/dirs it created after. Also, i noticed that all that stuff is owned by username-www instead of username. I tried chown, chmod and using a PHP script to do the same wti... (4 Replies)
Discussion started by: pentago
4 Replies

4. Shell Programming and Scripting

sort retrieved data files in different dirs

Hi, I have a script to retrieve data files from server and store them in a directory on local disk. The script runs everyday as cron job. But now those files are too many so my boss wants me to put the files into different directories base on dates. Those files look like this: ... (4 Replies)
Discussion started by: leafei
4 Replies

5. UNIX Desktop Questions & Answers

limit number of sub-dirs searched for files

using: find . -type f -print|xargs -li "string", how do I limit the dated directories (2010-7-14, 2010-7-13,etc.) to just 2009 & 2010 years of directories to search. We go back to 2004 in our archives, way too many files. (3 Replies)
Discussion started by: MJThom713
3 Replies

6. Shell Programming and Scripting

Have absolute path for files in different dirs

Hi everybody. I need a command to print the absolute path of files which name starts always with a pattern (MOD03), independently on where they are in the filesystem. I have tryedls -ld ${INPUTPREFIX}/*/*/* | grep MOD03 | awk '{ print $8 }'but I have to use "/*/*/*" in this case to have the... (5 Replies)
Discussion started by: canduc17
5 Replies

7. Shell Programming and Scripting

Find most recent files in dirs and tar them up?

Hey all.. This should be simple but stoopid here can't get head around it! I have many directories, say 100 each with many files inside. I need a script to traverse through the dirs, find most recent file in each dir and add it to a tar file. I can find the files with something like for... (1 Reply)
Discussion started by: bobdung
1 Replies

8. Shell Programming and Scripting

script find files in two dirs HELP

I have a directory which is /home/mark/files/ , inside this particular I have a bunch of filles (see examples below) TST_SHU_00014460_20090302.txt TST_SHU_00016047_20090302.txt TST_SHU_00007838_20090303.txt TST_SHU_00056485_20090303.txt TST_SHU_00014460_20090303.txt... (2 Replies)
Discussion started by: fierusbentus
2 Replies

9. UNIX for Dummies Questions & Answers

Forcing UID on Files/Dirs Created with SFTP?

I have a situation where I have to provide Windows based users with access to specific files and directories on a *nix web mail server. The users cannot use the CLI, so SSH is out. They've previously used a product called Webdrive to access *nix boxes via SFTP. The files and dirs they need... (5 Replies)
Discussion started by: deckard
5 Replies

10. UNIX for Dummies Questions & Answers

I need to ls all files in 4-6 deep dirs

I need to print to file , a listing of all files below a certain directory. Example: I need to print to file a listing of all files below the etc dir (including the subdirectories) with their full path. Any ideas on how to do this with one command. Or is this something I need to do on all... (4 Replies)
Discussion started by: gforty
4 Replies
Login or Register to Ask a Question