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)						    BSD General Commands Manual 						 SCRIPT(1)

NAME
script -- make typescript of terminal session SYNOPSIS
script [-a] [-f] [-q] [-t] [file] DESCRIPTION
Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. Options: -a Append the output to file or typescript, retaining the prior contents. -f Flush output after each write. This is nice for telecooperation: One person does `mkfifo foo; script -f foo' and another can super- vise real-time what is being done using `cat foo'. -q Be quiet. -t Output timeing data to standard error. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previous output. The second field indicates how many characters were output this time. This information can be used to replay typescripts with realistic typing and output delays. The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. Script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal. ENVIRONMENT
The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1) (for the history mechanism), replay(1). HISTORY
The script command appeared in 3.0BSD. BUGS
Script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. Linux July 30, 2000 Linux
All times are GMT -4. The time now is 06:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy