10-02-2009
Thanks Franklin!
I tested the second one. It works fine.
But i don't want to create another file. I tested the script as below
filename > filename. After executing the script, the <filename> becomes empty.
so isn't possible to remove the header & footer and store it in the same file itself?
Also can you tell me what is the difference between the first one and second one? i mean which will give give good performance?
Last edited by karthi_gana; 10-02-2009 at 01:30 PM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I get some flat files with trailer which gives the totol records count and i want to remove the trailer from the file.
i used the following command it works fine with a single file.
cat file_name | grep -v 'Total records:' > file1
mv file file_name
But i dont know how to remove the... (12 Replies)
Discussion started by: kumarsaravana_s
12 Replies
2. UNIX for Dummies Questions & Answers
All,
I am new to unix and i have the following requirement.
I have file(s) landing into input directory with timestamp, first i want to copy all these files into seperate directory then i want to rename these files without timestamp and also remove header,trailer from that file..
Could... (35 Replies)
Discussion started by: ksrams
35 Replies
3. Shell Programming and Scripting
Hi all,
I have a requirement to create a Header &Trailer for a file which is having 20 millions of records.
If I use the following method, i think it will take more time.
cat "Header"> file1.txt
cat Data_File>>file1.txt
cat "Trailer">>file1.txt
since second CAT command has to read all... (4 Replies)
Discussion started by: Raamc
4 Replies
4. Shell Programming and Scripting
How can we a shell script and pass date parameters .I have 3 files comming from Datastage with |" delimited
I need append 3 files as above: File1:
P0000|"47416954|"AU|"000|"INS|"0000|"|"20060601|"99991231|"|"|"|"|"01
File 2:... (2 Replies)
Discussion started by: e1994264
2 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I want to add the below Header to all the files in sequence File1,File2,File3...etc
"ABC,<number of chracter in the file>"
e,g - If File1 is as below
pqrstuvdt
abcdefgh
then I want to add the above header into it ,So that File1 becomes as below
ABC,17
pqrstuvdt
abcdefgh
... (9 Replies)
Discussion started by: spari2
9 Replies
6. Shell Programming and Scripting
Hi All,
I am trying write a simple command using AWK and SED to this but without any success.
Here is what I am using:
head -1 test1.txt>test2.txt|sed '1d;$d' test1.txt|awk '{print substr($0,0,(length($0)-2))}' >>test2.txt|tail -1 test1.txt>>test2.txt
Input:
Header
1234567
abcdefgh... (2 Replies)
Discussion started by: nvuradi
2 Replies
7. Shell Programming and Scripting
Hi,
I need a script that validates a file header/detail/trailer. File layout is:
Header - Rec_Type|File_name|File_Date
Detail - Rec_Type|field1|field2|field3...
Trailder - Rec_Type|File_name|File_Date|Record_count
Sample Data:
HDR|customer_data.dat|20120709... (7 Replies)
Discussion started by: ash_sh
7 Replies
8. Shell Programming and Scripting
please see my requirement, I hope I am clear. (9 Replies)
Discussion started by: mirwasim
9 Replies
9. Shell Programming and Scripting
I need to split the file based on pattern from position 34-37 while retaining the header and trailer records in each individual split file
Also is it possible to output the TOM and PAT records in the same output file ?
I need the output file names same as xyz_pattern_Datetimestamp.txt
... (23 Replies)
Discussion started by: techedipro
23 Replies
10. UNIX for Advanced & Expert Users
I have a EBCDIC multi layout file which has a header record which is 21 bytes, The Detail records are 2427 bytes long and the trailer record is 9 bytes long.
Is there a command to remove the header as well as trailer record and read only the detail records while at the same time not altering... (1 Reply)
Discussion started by: abhilashnair
1 Replies
LEARN ABOUT OPENSOLARIS
test
test(1F) FMLI Commands test(1F)
NAME
test - condition evaluation command
SYNOPSIS
test expression
expression
DESCRIPTION
test evaluates the expression expression and if its value is true, sets a 0 (TRUE) exit status; otherwise, a non-zero (FALSE) exit status
is set; test also sets a non-zero exit status if there are no arguments. When permissions are tested, the effective user ID of the process
is used.
All operators, flags, and brackets (brackets used as shown in the second SYNOPSIS line) must be separate arguments to test. Normally these
items are separated by spaces.
USAGE
Primitives
The following primitives are used to construct expression:
-r filename True if filename exists and is readable.
-w filename True if filename exists and is writable.
-x filename True if filename exists and is executable.
-f filename True if filename exists and is a regular file.
-d filename True if filename exists and is a directory.
-c filename True if filename exists and is a character special file.
-b filename True if filename exists and is a block special file.
-p filename True if filename exists and is a named pipe (FIFO).
-u filename True if filename exists and its set-user-ID bit is set.
-g filename True if filename exists and its set-group-ID bit is set.
-k filename True if filename exists and its sticky bit is set.
-s filename True if filename exists and has a size greater than 0.
-t[fildes] True if the open file whose file descriptor number is fildes (1 by default) is associated with a terminal device.
-z s1 True if the length of string s1 is 0.
-n s1 True if the length of the string s1 is non-zero.
s1 = s2 True if strings s1 and s2 are identical.
s1 != s2 True if strings s1 and s2 are not identical.
s1 True if s1 is not the null string.
n1 -eq n2 True if the integers n1 and n2 are algebraically equal. Any of the comparisons -ne, -gt, -ge, -lt, and -le may be used in
place of -eq.
Operators
These primaries may be combined with the following operators:
! Unary negation operator.
-a Binary and operator.
-o Binary or operator (-a has higher precedence than -o).
`(expression)` Parentheses for grouping. Notice also that parentheses are meaningful to the shell and, therefore, must be quoted.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
find(1), sh(1), attributes(5)
NOTES
If you test a file you own (the -r , -w , or -x tests), but the permission tested does not have the owner bit set, a non-zero (false) exit
status will be returned even though the file may have the group or other bit set for that permission. The correct exit status will be set
if you are super-user.
The = and != operators have a higher precedence than the -r through -n operators, and = and != always expect arguments; therefore, = and !=
cannot be used with the -r through -n operators.
If more than one argument follows the -r through -n operators, only the first argument is examined; the others are ignored, unless a -a or
a -o is the second argument.
SunOS 5.11 5 Jul 1990 test(1F)