02-01-2007
Read file based on condition
Hi Friends,
Can any one help with this:
I have a huge file with the format as
A SAM 4637
B DEPT1 4758 MILAN
A SMITH 46585
B DEPT2 5385 HARRYIS
B SAMUL 63547 GEORGE
B DANIEL 899 BOISE
A FRES 736 74638
I have to read this file and write only the records that starts with "B" only
output should be:
B DEPT1 4758 MILAN
B DEPT2 5385 HARRYIS
B SAMUL 63547 GEORGE
B DANIEL 899 BOISE
Thanks in advance
S
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a file given below. I want to split the file where ever I came across
***(instead you can put ### symbols in the file) . Also I need to name the file by extracting the report name from the first line which is in bold(eg:RPT507A) concatinated with DD(day on which the file runs). Can someone... (1 Reply)
Discussion started by: srivsn
1 Replies
2. Shell Programming and Scripting
Can any one help me to correct following script.
I have 2 directories DropZone and ProcessZone. File pattern is *VEHDESCSUM*.
Finding the 'no of files' in DropZone directory using ls *VEHDESCSUM* |wc -l
If DropZone has more than one file or 0 files then exit 1
If DropZone has one file then... (2 Replies)
Discussion started by: ramanagh
2 Replies
3. Shell Programming and Scripting
Hi,
I have a comma separated file with millions of records in it.
I have a requirement to split the file based on the value in a one of the columns.
Suppose i have a text file with columns like C1, C2,C3,C4
Column C4 can hold the values either 01 or 02 03 or 04.
I nned to extract... (2 Replies)
Discussion started by: Raamc
2 Replies
4. Shell Programming and Scripting
Hi
i am new to scripting. i have a file file.dat with content as :
CONTENT_STORAGE PERCENTAGE FLAG:
/storage_01 64% 0
/storage_02 17% 1
I need to update the value of FLAG for a particular CONTENT_STORAGE value
I have written the following code
#!/bin/sh
threshold=20... (1 Reply)
Discussion started by: kichu
1 Replies
5. Shell Programming and Scripting
Hello,
I have File1 in a directory A, a File2 in a directory B.
If the File2 is not empty
Then I have to move File1 from directory A to a directory archive
Else no action.
Is it possible to do this from one command line?
Thank you in advance for your answers.
Madi (2 Replies)
Discussion started by: AngelMady
2 Replies
6. Shell Programming and Scripting
Hi, Gurus,
I got a problem to resolve following issue:
I have one file file1as following:
start_dt=2010-01-01 12:00:02
start_dt=2011-01-01 09:00:02
start_dt=2009-01-01 11:00:02I have another file file2 as following:
title1, 2010-01-03 10:00:02
title2, 2011-01-04 11:00:02
title3,... (5 Replies)
Discussion started by: ken002
5 Replies
7. Shell Programming and Scripting
Experts,
What would be the code in ksh/perl to read 2 files alternatively, based on the following condition.
while reading file 1 we check if a blank line is encountered,
if yes, then we read file 2 unless a blank line is encountered in file 2
if we have a blank line in file 2 we come back... (3 Replies)
Discussion started by: suraj.sheikh
3 Replies
8. Shell Programming and Scripting
I collect data in a file in below format(Month Day Year Size) in RedHat Linux. Now i want to calculate the data size date wise. As i code shell script after long time, i forgot the features and syntax. Can anyone help me regard this please.
Feb 8 2014 15
Feb 10 2014 32
Feb 10 2014 32
Feb 12... (2 Replies)
Discussion started by: makauser
2 Replies
9. Shell Programming and Scripting
I want to keep last 2 days data from a file and want to delete others data from the file. Please help me.
Sample Input
# cat messages-2
Apr 15 11:25:03 test1 kernel: imklog 4.6.2, log source = /proc/kmsg started.
Apr 15 11:25:03 test1 rsyslogd: (re)start
Apr 16 19:42:03 test1 kernel:... (2 Replies)
Discussion started by: makauser
2 Replies
10. Shell Programming and Scripting
I have an input file like this...
All iI want to do is If the lines are identical except for the last field i want to merge them into single line
input_file
I feel something is nothing
I feel something is everything
apple mango banana
apple mango grapes
I want to get output like this:... (3 Replies)
Discussion started by: raj_k
3 Replies
LEARN ABOUT DEBIAN
date::hijri
Hijri(3pm) User Contributed Perl Documentation Hijri(3pm)
NAME
Date::Hijri - Perl extension to convert islamic (hijri) and gregorian dates.
SYNOPSIS
use Date::Hijri;
# convert gregorian to hijri date
my ($hd, $hm, $hy) = g2h($gd, $gm, $gy);
# convert hijri to gregorian date
my ($gd, $gm, $gy) = h2g($hd, $hm, $hy);
DESCRIPTION
This simple module converts gregorian dates to islamic (hijri) and vice versa.
The dates must be given as an array containing the day, month and year, and return the corresponding date as a list with the same elements.
EXAMPLES
#!/usr/bin/perl -w
use Date::Hijri;
print join("-", g2h(22,8,2003)); # prints 23-6-1424
print join("-", h2g(23,6,1424)); # prints 22-8-2003
SEE ALSO
This code is just stolen from KDE's kcalendarsystemhijri.cpp at
http://webcvs.kde.org/cgi-bin/cvsweb.cgi/kdelibs/kdecore/kcalendarsystemhijri.cpp
Copyright (c) 2002-2003 Carlos Moro <cfmoro@correo.uniovi.es>
Copyright (c) 2002-2003 Hans Petter Bieker <bieker@kde.org>
kcalendarsystemhijri.cpp is translated from the Lisp code
in ``Calendrical Calculations'' by Nachum Dershowitz and
Edward M. Reingold, Software---Practice & Experience,
vol. 20, no. 9 (September, 1990), pp. 899--928.
This code is in the public domain, but any use of it
should publically acknowledge its source.
AUTHOR
Alex Pleiner, <alex@zeitform.de>
COPYRIGHT AND LICENSE
Copyright (c) 2003 zeitform Internet Dienste. All rights reserved. This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
DISCLAIMER
I haven't really tested if the converted dates are right and hope someone will point out mistakes.
Hijri calculations are very difficult. The islamic calendar is a pure lunar calendar, the new month starts by a physical (i.e. human)
sighting of the crescent moon at a given locale. So it depends on several factors (like weather) that make it unreliable to calculate
islamic calendars in advance. As a result the dates calculated by Date::Hijri can be false by one or more days.
Please see http://www.rabiah.com/convert/introduction.html for further explanation.
I'm not a muslim, but interested in Islamic culture, religion and calendar system. I believe in the Internet as a chance to realize that we
live in a small world with multiple cultures, religions and philosophies. We can learn from others and develop tolerance, respect and
understanding.
Salam Alaikum (peace be with you)
perl v5.10.0 2003-08-26 Hijri(3pm)