Sponsored Content
Top Forums Shell Programming and Scripting File processing using script needs help Post 302358991 by nmadhuhb on Monday 5th of October 2009 12:07:50 PM
Old 10-05-2009
File processing using script needs help

Dear all,

Need help to write the shell script to process the file.

My requirement is script to process the file line by line and count the ids belong to the server name mentioned as in first field.

if
IN-S-BA1 is there count 4 lines and add the end of count echo the first filed and counted lines.

if IN-S-BA1 is 4
end of the count add one more line in file
IN-S-BA1:4

How can i Achieve this

example input file contains like this.

IN-S-BA1:root:account for OS Admin user:false:system,bin,sys,security,cron,audit,lp,
IN-S-BA1:daemon:account for daemon user:false:staff
IN-S-BA1:bin:account for bin user:false:bin,sys,adm
IN-S-BA1:sys:account for sys user:false:sys
IN-S-BA2:root:account for OS Admin user:false:system,bin,sys,security,cron,audit,lp,
IN-S-BA2:daemon:account for daemon user:false:staff
IN-S-BA2:bin:account for bin user:false:bin,sys,adm
IN-S-BA2:sys:account for sys user:false:sys
IN-S-BT1:root:account for OS Admin user:false:system,bin,sys,security,cron,audit,lp,
IN-S-BT1:daemon:account for daemon user:false:staff
IN-S-BT1:bin:account for bin user:false:bin,sys,adm
IN-S-BT1:sys:account for sys user:false:sys
IN-S-BQ1:root:account for OS Admin user:false:system,bin,sys,security,cron,audit,lp,
IN-S-BQ1:daemon:account for daemon user:false:staff
IN-S-BQ1:bin:account for bin user:false:bin,sys,adm
IN-S-BQ1:sys:account for sys user:false:sys
IN-S-BD1:root:account for OS Admin user:false:system,bin,sys,security,cron,audit,lp,
IN-S-BD1:daemon:account for daemon user:false:staff
IN-S-BD1:bin:account for bin user:false:bin,sys,adm
IN-S-BD1:root:account for adm user:false:adm

Outfile to be like below

IN-S-BA1:root:account for OS Admin user:false:system,bin,sys,security,cron,audit,lp,
IN-S-BA1:daemon:account for daemon user:false:staff
IN-S-BA1:bin:account for bin user:false:bin,sys,adm
IN-S-BA1:sys:account for sys user:false:sys
IN-S-BA1:4
IN-S-BA2:root:account for OS Admin user:false:system,bin,sys,security,cron,audit,lp,
IN-S-BA2:daemon:account for daemon user:false:staff
IN-S-BA2:bin:account for bin user:false:bin,sys,adm
IN-S-BA2:sys:account for sys user:false:sys
IN-S-BA2:4
IN-S-BT1:root:account for OS Admin user:false:system,bin,sys,security,cron,audit,lp,
IN-S-BT1:daemon:account for daemon user:false:staff
IN-S-BT1:bin:account for bin user:false:bin,sys,adm
IN-S-BT1:sys:account for sys user:false:sys
IN-S-BT1:4
IN-S-BQ1:root:account for OS Admin user:false:system,bin,sys,security,cron,audit,lp,
IN-S-BQ1:daemon:account for daemon user:false:staff
IN-S-BQ1:bin:account for bin user:false:bin,sys,adm
IN-S-BQ1:sys:account for sys user:false:sys
IN-S-BQ1:4
IN-S-BD1:root:account for OS Admin user:false:system,bin,sys,security,cron,audit,lp,
IN-S-BD1:daemon:account for daemon user:false:staff
IN-S-BD1:bin:account for bin user:false:bin,sys,adm
IN-S-BD1:root:account for adm user:false:adm
IN-S-BD1:4

Pl Help ....

Thanks in advance..

Madhu

Pl Help ....

Thanks in advance..

Madhu
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Have a shell script check for a file to exist before processing another file

I have a shell script that runs all the time looking for a certain type of file and then it processes the file through a series of other scripts. The script is watching a directory that has files uploaded to it via SFTP. It already checks the size of the file to make sure that it is not still... (3 Replies)
Discussion started by: heprox
3 Replies

2. Shell Programming and Scripting

perl script for file processing

Aim: To scan a file and ignore all characters that has an ASCII value from 0 to 31 and 127 to 255 and accept only those characters having an ASCII between 32 and 126. Script: #!/usr/local/bin/perl $filename = "$ARGV"; if (-e $filename) { open(OUT, "${filename}") || die "can't... (10 Replies)
Discussion started by: SEEHTAS
10 Replies

3. Shell Programming and Scripting

KSH script -text file processing NULL issues

I'm trying to strip any garbage that may be at the end of my text file and that part is working. The problem only seems to be with the really long lines in the file. When the head command is executed I am directing the output to a new file. The new file always get a null in the 4096 position but... (2 Replies)
Discussion started by: geauxsaints
2 Replies

4. Shell Programming and Scripting

awk, perl Script for processing a single line text file

I need a script to process a huge single line text file: The sample of the text is: "forward_inline_item": "Inline", "options_region_Australia": "Australia", "server_event_err_msg": "There was an error attempting to save", "Token": "Yes", "family": "Family","pwd_login_tab": "Enter Your... (1 Reply)
Discussion started by: hmsadiq
1 Replies

5. Shell Programming and Scripting

Simple Script needed for Processing CSV file perl

I am new to perl, and need a script to pull a CSV file, strip out 2 leading columns, and 2 ending columns, and resave the file in a new location. The file is basic and has less than 10,000 records. Secondly, can I schedule perl scripts to run daily? Can someone provide the basic script to... (1 Reply)
Discussion started by: cobbjob
1 Replies

6. Shell Programming and Scripting

2 file processing script in C shell

I want to use an awk for the following scenario but not sure if it will work or not. I have two input file: F1 and F2 F1 02 05 08 F2 00 01 02 03 04 05 06 07 08 09 10 (1 Reply)
Discussion started by: jclanc8
1 Replies

7. Shell Programming and Scripting

File Processing in shell script

i have a file with following type of data abcd : gggggg gggggg ; 1234 gggggg ; 5678 gggggg ; 3434 gggggg ; 6565 gggggg ; 1231 1234 ; vvvv ;Eng=Myfirstname 5678 ; xyzf ;Eng=Mysecondname 3434 ; xyzf ;Eng=Mythirdname 6565 ; xyzf ;Eng=Mysfourthname 1231 ; xyzf ;Eng=Mysfifthname... (7 Replies)
Discussion started by: telangmadhuri
7 Replies

8. Shell Programming and Scripting

Need help in File Processing Script

I made one script in shell, but it is not running in my server. So i am trying to make perl for the same. Can anyone help me? #!/bin/sh p=`date '+20%y%m%d'` cp Process_*"$p"*.txt /tmp/ cat /tmp/number.txt | egrep -v "Prefix|---|" | sed -e 's/ //g' -e '/^$/d' | nawk -F"->"... (4 Replies)
Discussion started by: lecria
4 Replies

9. Programming

awk processing / Shell Script Processing to remove columns text file

Hello, I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this : This is the output of ls command : I stored the output in a file filelist 1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies

10. Shell Programming and Scripting

How to log file processing details to database table usnig UNIX shell script?

we are getting files on daily basis.we need to process these files. i need a unix shell script where we can count 1-The no of files processed 2-No of data/record processed for each files. The script should log these details into a database table. If there is any error while file... (3 Replies)
Discussion started by: Atul kumar
3 Replies
script(1)							   User Commands							 script(1)

NAME
script - make record of a terminal session SYNOPSIS
script [-a] [filename] DESCRIPTION
The script utility makes a record of everything printed on your screen. The record is written to filename. If no file name is given, the record is saved in the file typescript. See WARNINGS. The script command forks and creates a sub-shell, according to the value of $SHELL, and records the text from this session. The script ends when the forked shell exits or when Control-d is typed. OPTIONS
The following option is supported: -a Appends the session record to filename, rather than overwriting it. NOTES
script places everything that appears on the screen in filename, including prompts. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) WARNINGS
script can pose a security risk when used in directories that are writable by other users (for example, /tmp), especially when run by a privileged user, that is, root. Be sure that typescript is not a link before running script. SunOS 5.11 30 Jan 2004 script(1)
All times are GMT -4. The time now is 09:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy