Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to add no. from different directory? Post 302934508 by Don Cragun on Sunday 8th of February 2015 04:14:56 AM
Old 02-08-2015
Assuming that all of your filenames follow the same pattern, you could try something like:
Code:
#!/bin/ksh
date=$(date +"%Y%m%d")
(	cd sms_files_2/name_files/
	wc -l *$date*
	cd -
	cd sms_files_3/name_files/
	wc -l *$date*
) | awk -F'[ _]*' '
substr($5, 3, 1) == "C" && substr($6, 3, 1) == "T" {
	c[$5 "   " $6] += $2
}
END {	for(i in c)
		printf("%d   %s\n", c[i], i)
}' | sort -k2

which, with your sample input, produces the output:
Code:
400000   1-C2014020657   1-T2014020668
494160   1-C2014020671   1-T2014020679
400000   1-C2014020672   1-T2014020680

If the output order doesn't have to be sorted, remove the:
Code:
 | sort -k2

from the last line of the script.

Although written and tested using the Korn shell, this script will work with any POSIX-conforming shell such as bash and ksh.

If you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk, /usr/xpg6/bin/awk, or nawk.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

add user, directory, etc. via cgi

Hello All (yes I mean you): I'm a self taught programmer, so please bear with me and my ignorance. What I Am Trying To Do: I am attempting to create a user (and all the accompanying attributes like a home directory, entry in the passwd file, disk quota allotment and skel selection for a... (1 Reply)
Discussion started by: gfoxjr
1 Replies

2. UNIX for Dummies Questions & Answers

how to add permission of directory to a group

Hi, A simple and silly question on Unix. I have a directory named "a" and I would like to grant permission to group name "text" to access, read and execute my directory. Could anyone help me? Thanks. (2 Replies)
Discussion started by: ahjiefreak
2 Replies

3. Shell Programming and Scripting

Add 5 lines of code to all the scripts in a directory

Hi Guys, I need some tips on writing a Korn shell script that would look for certain lines of code and replace all the scripts in the directory with a few other lines. I have about 120 scripts that I need to modify. Any suggestions would be appreciated! Thanks, Cool_avi (5 Replies)
Discussion started by: coolavi
5 Replies

4. Shell Programming and Scripting

add user script while looking for directory

sorry didnt see that thread at first thanks (1 Reply)
Discussion started by: pbhound
1 Replies

5. UNIX for Dummies Questions & Answers

Add directory to a global PATH

Guys, I did a search on this but couldn't find any thing. I need to add /home/scadm/scripts to the PATH. If I do the below it works for the session I'm in. If I close it and reopen it doesnt work. PATH=$PATH\:/home/scadm/scripts ; export PATH I also want this path added to all the... (3 Replies)
Discussion started by: miltonrods
3 Replies

6. Shell Programming and Scripting

Can't add directory to path correctly

Hello everyone I am a newcomer to UNIX and I have hit a snag in something that would probably take experienced people about 30 seconds. Long story short I am trying to add a directory to my PATH and it is getting added but not working. I mean, the object of adding it to the path is so I can access... (2 Replies)
Discussion started by: tastybrownies
2 Replies

7. AIX

Can we add multiple groups to a directory or a file ?

Hello, drwxr-x--- 21 root system 4096 Jan 25 10:20 /testdir here owner is root, group is system. 1) is it possible to add multiple groups to "/testdir" files/directories ? if yes, please provide me the command. my requirement is to provide read-only access to user1 on /testdir... (6 Replies)
Discussion started by: aaron8667
6 Replies

8. Red Hat

How can I add to Active Directory with Samba Linux?

hi How do I update this file /etc/samba/smb.conf Linux be added to Active Directory thanks (0 Replies)
Discussion started by: mnnn
0 Replies

9. Shell Programming and Scripting

Add part of directory name to filename

Hello, I need to add a part of folder name to the files inside it. For instance the file is HMCBackup_20150430.155027.tgz and it is under directory /nim/dr/HMCBackup/cops22 I need to add cops22 to the file name so as it would be cops22_HMCBackup_20150430.155027.tgz Any help in doing... (10 Replies)
Discussion started by: hasn318
10 Replies

10. Red Hat

Add directory to path permanently

I ssh in and am trying to add a directory permanently to $PATH in centos 7 and having issues. My current $PATH is echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin but when I do a sudo nano ~/.bashrc # .bashrc # User specific aliases and functions alias... (7 Replies)
Discussion started by: cmccabe
7 Replies
PAPS(1) 						      General Commands Manual							   PAPS(1)

NAME
paps - UTF-8 to PostScript converter using Pango SYNOPSIS
paps [options] files... DESCRIPTION
paps reads a UTF-8 encoded file and generates a PostScript language rendering of the file. The rendering is done by creating outline curves through the pango ft2 backend. OPTIONS
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. --landscape Landscape output. Default is portrait. --columns=cl Number of columns output. Default is 1. Please notice this option isn't related to the terminal length as in a "80 culums terminal". --font=desc Set the font description. Default is Monospace 12. --rtl Do right to left (RTL) layout. --paper ps Choose paper size. Known paper sizes are legal, letter and A4. Default is A4. Postscript points Each postscript point equals to 1/72 of an inch. 36 points are 1/2 of an inch. --bottom-margin=bm Set bottom margin. Default is 36 postscript points. --top-margin=tm Set top margin. Default is 36 postscript points. --left-margin=lm Set left margin. Default is 36 postscript points. --right-margin=rm Set right margin. Default is 36 postscript points. --gutter-width=gw Set gutter width. Default is 40 postscript points. --help Show summary of options. --header Draw page header for each page. --markup Interpret the text as pango markup. --lpi Set the lines per inch. This determines the line spacing. --cpi Set the characters per inch. This is an alternative method of specifying the font size. --stretch-chars Indicates that characters should be stretched in the y-direction to fill up their vertical space. This is similar to the texttops behaviour. AUTHOR
paps was written by Dov Grobgeld <dov.grobgeld@gmail.com>. This manual page was written by Lior Kaplan <kaplan@debian.org>, for the Debian project (but may be used by others). April 17, 2006 PAPS(1)
All times are GMT -4. The time now is 06:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy