01-19-2011
Reading only first record from the multipe directories
Hi All,
I have a requirement, I had a parent directory Land under that we have sub directories
Yesterday,
Today and
Tommorrow
And we have a file test.txt under the above directories Yesterday, Today and Tommorrow
The data in the file test.txt under Yesterday folder is
Header|2011-12-01
DATA|TOTAL1
DATA|TOTAL2
EOF
The data in the file test.txt under Today folder is
Header|2011-13-01
DATA|TOTAL3
DATA|TOTAL4
EOF
The data in the file test.txt under Tommorrow folder is
Header|2011-14-01
DATA|TOTAL5
DATA|TOTAL6
EOF
I want to get only the 1st records after removing header records from the files like below
DATA|TOTAL1
DATA|TOTAL3
DATA|TOTAL5
I used below command
I used below command awk -F"|" 'BEGIN{IGNORECASE=1;} $1~/DATA/' Land/*/test.txt
I'm getting all the records and the data is as shown below
DATA|TOTAL1
DATA|TOTAL2
DATA|TOTAL3
DATA|TOTAL4
DATA|TOTAL5
DATA|TOTAL6
Thanks,
Raju
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi, people.
I was searching script tutorials/examples and found this forum, and thought to ask for help, because there seems to be many wise people here.
(Try to bare with me, I'm a Windows user, so this stuff is somewhat strange to me, OK? :rolleyes: )
Anyways, I need to create a script that... (3 Replies)
Discussion started by: Gill Bates
3 Replies
2. UNIX for Dummies Questions & Answers
I have a file in following format
directory1=/out/log
purgedays1=4
extn1=log,out,txt
directory2=/clean/log
purgedays2=4
extn2=log,out
now i need need to create a script that reads this file and cleans all the files with the given extn from the given directory.
The catch here is that... (2 Replies)
Discussion started by: max_payne1234
2 Replies
3. Shell Programming and Scripting
Hi,
I am trying to create a while loop that will do the following:
INFILE= list of new records that need to be added after last previous record
while read record
do
find the last record processed
create list of new records output to a file
echo "$record">> $NEWFILE
done
... (9 Replies)
Discussion started by: shortyball24
9 Replies
4. Shell Programming and Scripting
Hi Guys,
I need to check whether the last column is RP, If so, then i have to second column and pass it to a select statement as sonid and fetch the value to a variable and run it. This has to be done till the last column is RW.
value Fatherid sonid topid ... (8 Replies)
Discussion started by: mac4rfree
8 Replies
5. Shell Programming and Scripting
I am trying to read a file in a shl script (only one record) and stored in a variable file_number
I got the following
read -u $BANNER_HOME/xxxxxxx/misc/EFTSQL.dat file_number
file_number2 = $file_number + 1
echo $file_number2 > $BANNER_HOME/xxxxxx/misc/EFTSQL.dat
EOF
It is not working... (2 Replies)
Discussion started by: rechever
2 Replies
6. Shell Programming and Scripting
Hi friends,
I have small query with reg to awk search pattern..
below is my sample file and code which i tried..
$ cat file.txt
xxx,yyyyy,messageID,sha
xxxx,errorcode,messageID,name
in the above sample file - let assume I know the errorcode(2nd record) using which I want to... (2 Replies)
Discussion started by: Shahul
2 Replies
7. Shell Programming and Scripting
Hi
Need urgent help (2 Replies)
Discussion started by: premp26
2 Replies
8. Shell Programming and Scripting
Hi all,
I have some directory structure as
$ls -ltr
drwxr-xr-x 1 mscprod us_msc 512 May 10 08:34 650
drwxr-xr-x 1 mscprod us_msc 512 May 10 08:51 652
drwxr-xr-x 1 mscprod us_msc 512 May 10 08:51 640
drwxr-xr-x 1 mscprod us_msc512 May 10 09:13 654
$ cd 650/
$ls
fileabc.root
and within... (7 Replies)
Discussion started by: emily
7 Replies
9. Shell Programming and Scripting
Hello
I'm making script for Dallas temperature sensors (DS1820).
When a sensor is connected, it shows up as a directory in /sys/bus/w1/devices
in format 10-xxxxxxx. Inside the directory is a file called w1_slave which holds the temperature in format t=xxxxx.
Each sensor has unique... (2 Replies)
Discussion started by: Klipeti
2 Replies
10. UNIX for Dummies Questions & Answers
Hi,
In a parent directory there are several files in the form
IDENTIFIER1x
IDENTIFIER1.yyy
IDENTIFIER1_Z, etc
IDENTIFIER2x
IDENTIFIER2.yyy
IDENTIFIER2_Z, etc
IDENTIFIER3x
IDENTIFIER3.yyy,
IDENTIFIER3_Z, etcIn the same parent directory there are corresponding directories named... (7 Replies)
Discussion started by: spirospap
7 Replies
LEARN ABOUT POSIX
getptype
GETPTYPE(3) MBK UTILITY FUNCTIONS GETPTYPE(3)
NAME
getptype - retrieve a ptype from a ptype_list
ORIGIN
This software belongs to the ALLIANCE CAD SYSTEM developed by the ASIM team at LIP6 laboratory of Universite Pierre et Marie CURIE, in
Paris, France.
Web : http://asim.lip6.fr/recherche/alliance/
E-mail : alliance-users@asim.lip6.fr
SYNOPSYS
#include "mut.h"
ptype_list *getptype(pthead,type)
ptype_list *pthead;
long type;
PARAMETERS
pthead Pointer to a ptype list
type Flag indicating the pointer owner
DESCRIPTION
getptype looks for a ptype element in the list pointed to by pthead.
RETURN VALUE
getptype returns a pointer to the ptype that match the type. Be careful, it is not the ptype->DATA that is returned. If no ptype has the
given type, then NULL is returned.
EXAMPLE
#include "mut.h"
#include "mph.h"
void get_corner(ptfig, name, x2, y2)
phfig_list *ptfig;
char *name;
int *x2, *y2;
{
phins_list *i = getphins(ptfig, name);
ptype_list *p = getptype(i->USER, (long)PLACEABOX);
*x2 = (num_list *)(p->DATA)->DATA;
*y2 = (num_list *)(p->DATA)->NEXT->DATA;
}
SEE ALSO
mbk(1), ptype(3), addptype(3), freeptype(3), delptype(3).
BUG REPORT
This tool is under development at the ASIM department of the LIP6 laboratory.
We need your feedback to improve documentation and tools.
ASIM
/LIP6 October 1, 1997 GETPTYPE(3)