Sponsored Content
Top Forums Shell Programming and Scripting Extract error records based on specific criteria from Unix file Post 302670255 by ratheesh2011 on Thursday 12th of July 2012 01:01:25 AM
Old 07-12-2012
Extract error records based on specific criteria from Unix file

Hi,

I look for a awk one liner for below issue.

input file

Code:
ABC 1234 abc 12345
ABC 4567 678 XYZ
xyz ght 678
ABC 787 yyuu
ABC 789 7890 777
zxr hyip hyu
mno uii 678 776
ABC ty7 888

All lines should be started with ABC as first field. If a record has another value for 1st field, the previuos record with ABC also an error record. I need to get the output as below

Code:
ABC 4567 678 XYZ
xyz ght 678
ABC 789 7890 777
zxr hyip hyu
mno uii 678 776

i have written a code by using while ... do ... done. but for bigger files this takes lot of time as this code reads file record by record.
Please help.

Thanks
RAR.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Select records based on search criteria on first column

Hi All, I need to select only those records having a non zero record in the first column of a comma delimited file. Suppose my input file is having data like: "0","01/08/2005 07:11:15",1,1,"Created",,"01/08/2005" "0","01/08/2005 07:12:40",1,1,"Created",,"01/08/2005"... (2 Replies)
Discussion started by: shashi_kiran_v
2 Replies

2. Shell Programming and Scripting

Append specific lines to a previous line based on sequential search criteria

I'll try explain this as best I can. Let me know if it is not clear. I have large text files that contain data as such: 143593502 09-08-20 09:02:13 xxxxxxxxxxx xxxxxxxxxxx 09-08-20 09:02:11 N line 1 test line 2 test line 3 test 143593503 09-08-20 09:02:13... (3 Replies)
Discussion started by: jesse
3 Replies

3. UNIX for Dummies Questions & Answers

Extract a specific number from an XML file based on the start and end tags

Hello People, I have the following contents in an XML file ........... ........... .......... ........... <Details = "Sample Details"> <Name>Bob</Name> <Age>34</Age> <Address>CA</Address> <ContactNumber>1234</ContactNumber> </Details> ........... ............. .............. (4 Replies)
Discussion started by: sushant172
4 Replies

4. Shell Programming and Scripting

Extract data based on specific search criteria

I have a huge file (about 2 millions records) contains data separated by “,” (comma). As part of the requirement, I can't change the format. The objective is to remove some of the records with the following condition. If the 23rd field on each line start with 302 , I need to remove that from the... (4 Replies)
Discussion started by: jaygamini
4 Replies

5. Shell Programming and Scripting

Extract file records based on some field conditions

Hello Friends, I have a file(InputFile.csv) with the following columns(the columns are pipe-delimited): ColA|ColB|ColC|ColD|ColE|ColF Now for this file, I have to get those records which fulfil the following condition: If "ColB" is NOT NULL and "ColD" has values one of the following... (9 Replies)
Discussion started by: mehimadri
9 Replies

6. Shell Programming and Scripting

Extract records from Oracle to UNIX file with headers

Hi, I have a shell script which extracts records form oracle to unix file. sqlplus -s ${WMD_DM_CONNECT} <<EOF >$tmpfile set heading off set pagesize 0 set feedback off select CD_DESC||'|'||CD_ID||'|'||'Arun'||'|'||'Montu' from WMD_SYS_CD_LKUP where CD_TYP =... (5 Replies)
Discussion started by: Arun Mishra
5 Replies

7. Shell Programming and Scripting

Extract specific lines based on another file

I have a folder containing text files. I need to extract specific lines from the files of this folder based on another file input.txt. How can I do this with awk/sed? file1 ARG 81.9 8 81.9 0 LEU 27.1 9 27.1 0 PHE .0 10 .0 0 ASP 59.8 11 59.8 0 ASN 27.6 12 27.6 0 ALA .0 13 .0 0... (5 Replies)
Discussion started by: alanmathew84
5 Replies

8. Shell Programming and Scripting

awk to print specific line in file based on criteria

In the file below I am trying to extract a specific instance of path, if the adjacent plugin": "/rundb/api/v1/plugin/49/. Thank you :). file "path": "/results/analysis/output/Home/Auto_user_S5-00580-4-Medexome_65_028/plugin_out/FileExporter_out.52", "plugin": "/rundb/api/v1/plugin/49/",... (8 Replies)
Discussion started by: cmccabe
8 Replies

9. Shell Programming and Scripting

Need a Linux command for find/replace column based on specific criteria.

I'm new to shell programming, I have a huge text file in the following format, where columns are separated by single space: ACA MEX 4O_ $98.00 $127.40 $166.60 0:00 0:00 0 ; ACA YUL TS_ $300.00 $390.00 $510.00 0:00 0:00 0 ; ACA YYZ TS_ $300.00 $390.00 $510.00 0:00 0:00 0 ; ADZ YUL TS_ $300.00... (3 Replies)
Discussion started by: transat
3 Replies

10. Shell Programming and Scripting

Awk/sed/cut to filter out records from a file based on criteria

I have two files and would need to filter out records based on certain criteria, these column are of variable lengths, but the lengths are uniform throughout all the records of the file. I have shown a sample of three records below. Line 1-9 is the item number "0227546_1" in the case of the first... (15 Replies)
Discussion started by: MIA651
15 Replies
FS_LSMOUNT(1)						       AFS Command Reference						     FS_LSMOUNT(1)

NAME
fs_lsmount - Reports the volume for which a directory is the mount point. SYNOPSIS
fs lsmount -dir <directory>+ [-help] fs ls -d <directory>+ [-h] DESCRIPTION
The fs lsmount command reports the volume for which each specified directory is a mount point, or indicates with an error message that a directory is not a mount point or is not in AFS. To create a mount point, use the fs mkmount command. To remove one, use the fs rmmount command. OPTIONS
-dir <directory>+ Names the directory that serves as a mount point for a volume. The last element in the pathname provided must be an actual name, not a shorthand notation such as one or two periods ("." or ".."). -help Prints the online help for this command. All other valid options are ignored. OUTPUT
If the specified directory is a mount point, the output is of the following form: '<directory>' is a mount point for volume '<volume name>' where o A number sign ("#") precedes the <volume name> string for a regular mount point. o A percent sign ("%") precedes the <volume name> string for a read/write mount point. o A cell name and colon (":") follow the number or percent sign and precede the <volume name> string for a cellular mount point. The fs mkmount reference page explains how the Cache Manager interprets each of the three types of mount points. If the directory is a symbolic link to a mount point, the output is of the form: '<directory>' is a symbolic link, leading to a mount point for volume '<volume name>' If the directory is not a mount point or is not in AFS, the output reads: '<directory>' is not a mount point. If the output is garbled, it is possible that the mount point has become corrupted in the local AFS client cache. Use the fs flushmount command to discard it, which forces the Cache Manager to refetch the mount point. EXAMPLES
The following example shows the mount point for the home directory of user "smith": % fs lsmount /afs/abc.com/usr/smith '/afs/abc.com/usr/smith' is a mount point for volume '#user.smith' The following example shows both the regular and read/write mount points for the ABC Corporation cell's "root.cell" volume. % fs lsmount /afs/abc.com '/afs/abc.com' is a mount point for volume '#root.cell' % fs lsmount /afs/.abc.com '/afs/.abc.com' is a mount point for volume '%root.cell' The following example shows a cellular mount point: the State University cell's "root.cell" volume as mounted in the ABC Corporation cell's tree. % fs lsmount /afs/stateu.edu '/afs/stateu.edu' is a mount point for volume '#stateu.edu:root.cell' PRIVILEGE REQUIRED
The issuer must have the "l" (lookup) permission on the ACL of the root directory of the volume that houses the file or directory named by the -dir argument, and on the ACL of each directory that precedes it in the pathname. SEE ALSO
fs_flushmount(1), fs_mkmount(1), fs_rmmount(1) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2012-03-26 FS_LSMOUNT(1)
All times are GMT -4. The time now is 07:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy