11-04-2005
Need help with the syntax using awk+grep
Hi,
I need to extract information from a 4 GB file based on the following conditions:
1) Check for the presence of a set of account numbers
Each account number is present along with other information within
a PAGESTART and PAGEEND.
The file looks like this:
PAGESTART
ACCOUNT NO 123
DATE 10-01-2004
money 10982
PAGEEND
PAGESTART
ACCOUNT NO 245
DATE 10-03-2005
MONEY 254
PAGEND
2) If the account numbers are present then the information corresponding PAGESTART and PAGEEND must be determined.
If one of the specified account no is 123,
I require the following information
PAGESTART
ACCOUNT NO 123
DATE 10-01-2004
money 10982
PAGEEND
Can anyone help with this!!
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I wanna grep for a pattern logs 1 2 & 3 within a folder containing 100 logs
grep "test" /folder/log1 /folder/log2 /folder/log3
The above command will work fine
but is there any command like
grep "test" /folder/log1, log2, log3 or something similar (4 Replies)
Discussion started by: roshanjain2
4 Replies
2. BSD
I'm learning UNIX on my mac (BSD), using a manual. I'm trying to figure out the grep command, and am getting something wrong. I've opened one of my files in NeoOffice and am looking for a string, the phrase 'I am writing.' I've been to some sites to get the proper syntax, and from what I can see... (5 Replies)
Discussion started by: Straitsfan
5 Replies
3. UNIX for Dummies Questions & Answers
Hello,
This is my first post so, Hello World! Anyways, I'm learning how to use unix and its quickly become apparent that a strong foundation in regular expressions will make things easier. I'm not sure if my syntax is messing things up or my logic is messing things up.
ps -e | grep... (4 Replies)
Discussion started by: MykC
4 Replies
4. UNIX for Dummies Questions & Answers
Hello,
I'm working on learning regular expressions and what I can do with them. I'm using unix to and its programs to experiment and learn what my limitations are with them.
I'm working on duplicating the regular expression:
^(.*)(\r?\n\1)+$
This is supposed to delete duplicate lines... (2 Replies)
Discussion started by: MykC
2 Replies
5. UNIX for Dummies Questions & Answers
Hello,
I'm working on unix with grep (GNU grep) 2.5.1. I'm going through some of the newer regex syntax using Regular Expression Reference - Advanced Syntax a guide.
ls -aLl /bin | grep "\(x\)"
Which works, just highlights 'x' where ever, when ever.
I'm trying to to get (?:) to work but... (4 Replies)
Discussion started by: MykC
4 Replies
6. Shell Programming and Scripting
Alrighty, I'm trying to get a perl script going to search through a bunch of files for me and compile it to a single location. I am currently having troubles on just getting the grep to work.
Here is what I currently have:
#!/usr/bin/perl
open (LOG, "errors.txt") or die
("Unable to open... (2 Replies)
Discussion started by: adelsin
2 Replies
7. UNIX for Dummies Questions & Answers
Hi Folks,
I am trying to dig through about 100 directories that have 1 or 2 .jpg images stored in each. I want to copy the .jpg to another file in the root directory. Really my ultimate goal is not to have to dig down into each directory to copy the images individually. I thought I could use a... (2 Replies)
Discussion started by: alpinescott
2 Replies
8. Shell Programming and Scripting
My current code is:
user@ubuntu:~/Desktop$ grep -e "\(packaged by\)\|\(employee\)\|\(file name\)\|\(Total Data (MB) Read\)\|\(Begin Time\)" log.txt
packaged by = Ron Mexico
employee = Michael Vick
file name = Mike_Vick_2011.bat
Total Data (MB) Read: 11.82
Begin Time: 6/13/2011... (8 Replies)
Discussion started by: chipperuga
8 Replies
9. Shell Programming and Scripting
Dear Team
/app/Appln/logs/
echo Session used server are 'grep -i pid|grep -i session | cut -d'.' -f1 | awk '{print $9}' | sort | uniq'
Output -
lxserver01
lxserver02
lxserver03
When I grep session pid in logs server details I can see above distinct server details but I... (6 Replies)
Discussion started by: skp
6 Replies
10. UNIX for Beginners Questions & Answers
I have a question to this command
find . -type f -name ".*txt" -exec grep "text" {}\.
The find command will locate a file name with the extension of txt once per round and find the word "text" in the content of the file or the find command will locate all the file names with the extension of... (2 Replies)
Discussion started by: TestKing
2 Replies
LEARN ABOUT HPUX
userstat
userstat(1M) userstat(1M)
NAME
userstat - check status of local user accounts
SYNOPSIS
[parm]...
[parm]...
DESCRIPTION
checks the status of local user accounts and reports abnormal conditions, such as account locks.
If any parm arguments are specified, abnormal status is displayed only for those parameters, otherwise abnormal status is displayed for all
parameters. The section describes the various parameter values that can be used for parm.
Each account with an abnormal status is displayed on a single line. Each line contains the username followed by one or more parameters,
indicating what abnormal conditions exist for the account. The section describes the various parameters that can be displayed.
Options
The following options are recognized:
Display the status of all users listed in
(Quiet) Do not print anything to standard output.
This can be used when interested only in the return value.
Check the status of only the specified user
name. The user must be a local user listed in
Parameters
The parameters that could be displayed to indicate abnormal account status, or that could be used with the option, include the following:
is displayed if an administrator lock is present on the account. This lock indicates that the encrypted password in or begins with An
administrator lock can be set, for example, with
is displayed if the account is locked because the account expiration
date has been reached. days is the number of days that the account has been expired. See the description of the expiration field
in shadow(4).
is displayed if the account's password has expired.
days is the number of days that the password has been expired. days is displayed only if its value can be determined.
is displayed if the account is locked because there have been no logins
to the account for a time interval that exceeds the maximum allowed. days is the number of days that the account has been inactive.
See the description of the attribute in security(4).
is displayed if the account is locked because the number of
consecutive authentication failures exceeded the maximum allowed. num is the number of consecutive authentication failures. See
the description of the attribute in security(4).
is displayed if the account is locked because the account has
a null password and is not allowed to have a null password. See the description of the attribute in security(4).
is displayed if the account has a time-of-day login restriction.
times defines the time periods that the user may login. See the description of the attribute in security(4).
Security Restrictions
Users invoking this command must have the authorization. See authadm(1M).
is not supported for trusted systems.
RETURN VALUE
exits with one of the following values:
did not find abnormal status
found abnormal status
invalid usage or user not found
EXAMPLES
The following example reports all abnormal status for all local accounts.
The following example shows that the account for user is not locked due to too many consecutive authentication failures.
FILES
standard password file
shadow password file
user database
SEE ALSO
authadm(1M), passwd(4), security(4), shadow(4), userdb(4).
userstat(1M)