My Apologies for confusing you again AWK commands are perfectly working fine and it splits file correctly as expected
Hope I am not confusing you further
1) If my input file name is sampletest_111.xml after AWK command file name will be like sampletest_111.xml.0001
2)sampletest_111.xml.0001 is renamed to Extrfile111.xml
3)when there are multiple input files AWK is spliting files and creating unique files but
below piece of code is not renaming files in a sequence its just appending to 1 file
Output Expected:Extrfile111.xml,Extrfile1112.xml etc i mean unique name
Total code :
xml_tag_handler.awk:
File_split.awk
#8 in the same thread got the sample xml structure for your reference
My Apologies for confusing you again AWK commands are perfectly working fine and it splits file correctly as expected
Hope I am not confusing you further
1) If my input file name is sampletest_111.xml after AWK command file name will be like sampletest_111.xml.0001
2)sampletest_111.xml.0001 is renamed to Extrfile111.xml
3)when there are multiple input files AWK is spliting files and creating unique files but
below piece of code is not renaming files in a sequence its just appending to 1 file
Output Expected:Extrfile111.xml,Extrfile1112.xml etc i mean unique name
... ... ...
Hi karthik,
I am not confused at all this time. Please go back and read closely what I said in post #28!
I don't care how well your awk script works when you invoke it with the name of a file to be processed. The script you showed us in post #27 NEVER EVER under any circumstances invokes awk; not even once! And, if your script doesn't run awk, it just plain is not possible that awk is splitting anything.
Showing us a few hundred more lines of awk code doesn't alter the fact that you are never running that code.
Until you alter the code that is initializing the FileList array correctly, there is nothing else to talk about. If you change the sixth line in your script from:
to:
and look at the output that line produces when you run your script, maybe you'll believe me. And, yes, I noticed that you changed the way you initialized that array from:
to:
but it doesn't alter the fact that the FileList array will still be an empty array and your awk script will never be executed. The empty line produced by the echo in your script should have been a strong indication to you that something was wrong, but you seem to be ignoring that fact. With the above change, hopefully it will be crystal clear.
The grep utility takes a basic regular expression as its first operand; not a filename matching pattern. BREs and filename matching patters have some similarities, but they are not the same. Since none of your filenames contain a literal backslash character (i.e. \), the grep can't match any lines in the output produced by ls.
You would do well to change the second line in your script from an empty line to:
to enable tracing so you can actually see what your script is doing.
See the below it is able to find the input files and i have pasted my output in debug mode it is able to rename only 1 file Extrfile112.xml where as it ignored or not able to
read sampletest_111.xml is the issue
OK. You lucked out... The BRE sampletest*\\_[0-9] tells grep to match and print lines that contain the string sampletes followed by zero or more occurrences of t followed by whatever unspecified characters are matched by the character sequence \_ on the regular expression matching engine used on your operating system followed by a decimal digit. It looks like your operating system's RE matching engine chooses to use that sequence to match an underscore character,
To match the filenames you want to process, the following BRE would work more reliably:
If you want to exclude matching filenames like sampletest_112.xml.0001, you could force the xml to only be matched at the end of a filename with:
Now that we have gotten past that... What statement in your script is failing to do what you want it to do? What are the arguments being passed to that command according to the trace output you're seeing? What arguments did you hope would be passed to that command instead of the arguments that are actually being passed to that command?
I have corrected the grep command as suggested now the issue is after split it will create multiple files with ending like below but see the mv command its moving all the files to 1 single file basically Extrfile110.xml it should create new unique file kindly suggest where iam goin wrong
ex:
sampletest_111.xml.0001
sampletest_112.xml.000i --- Post updated at 11:25 PM ---
Quote:
Originally Posted by karthik
Hi Don,
I have corrected the grep command as suggested now the issue is after split it will create multiple files with ending like below but see the mv command its moving all the files to 1 single file basically Extrfile110.xml it should create new unique file kindly suggest where iam goin wrong
You have an awk script that is creating uniquely named files. You then add another loop following your awk script that removes the final part of those filenames taking away the part that makes them unique and guarantees that only the last file created by each invocation of your awk script will be kept as the renaming loop overwrites each of the output files with the next output file in sequence.
If you want unique names, why do you have the renaming loop that intentionally strips off the part of their names that makes them unique?
The reason I am renaming split file is to convert that to proper xml name thats the reason I am renaming after that it invokes a wsdl
My Expected Output should look like below or any sequence will do but .xml should be there at the end
Hi There!
I am saving the file count of all files in a directory to an output file using:
wc -l * > FileCount.txt
I get:
114 G4SXORD
3 G4SXORH
0 G4SXORP
117 total
But this count includes header and footer. I want to subtract 2 from the count and get
... (7 Replies)
Hi Every one,
what is the coomand to remove header or footer from a file.
Please help me by providing command/syntax to remove header/footer from unix.
Thanks in advance for all your support. (5 Replies)
This is my file(Target.txt)
name|age|locaction
abc|23|del
xyz|24|mum
jkl|25|kol
The file should be like this
1|03252012
1|name|age|location
2|abc|23|del
2|xyz|24|mum
2|jkl|25|kol
2|kkk|26|hyd
3|4
Column 1 is row indicator
for row 1 and 2, column indicator is 1,for data rows... (1 Reply)
I am having report file with header and footer . The details in between header and footer are separated by a pipe charater. I want to sort the file by considering multiple columns in between header and footer.
pls help (4 Replies)
I have one large file, after every 200 line i have to split the file and the add header and footer to each small file?
It is possible to add different header and footer to each file? (7 Replies)
I have one large file, after every 200 line i have to split the file and the add header and footer to each small file?
It is possible to add different header and footer to each file? (1 Reply)
I am trying to get a total number of tapes w/out headers or footers in a ERV file and append it to the file. For some reason I cannot get it to work. Any ideas?
#!/bin/sh
dat=`date +"%b%d_%Y"`
+ date +%b%d_%Y
dat=Nov16_2006
tapemgr="/export/home/legato/tapemgr/rpts"... (1 Reply)
Hi, I need to chope the header and footer record from an input file and make a new output file, please let me know how i can do it in unix.thanks. (4 Replies)