last day (14 days later) » 

8:43 AM
0
A: short script to process a directory full of files, one by one, maintaining names

AbhayThat's easily done: Assuming your current directory is where the files are: for f in *.xml ; do echo $f | grep -q '_output\.xml$' && continue # skip output files g="$(basename $f .xml)_output.xml" command a_lot_of_arguments $f more_arguments >> $g done Though I wonder whether you w...

 
it seems to be calling the code properly, but the output files are all empty
 
Try it just for one file, replacing $f and $g by actual names, and see if the file is still empty. I mean without the loop.
 
in the original question under update i posted what was happening, it was kind of like a runaway freight train, like I guess it would have just kept going in the way of 1_output_output_output_output.xml, you know what I mean?
good idea, i'll try that out, with names and no loop.
 
Ah! I should have known! Ok, will update.
Added a line to skip output files. Now before trying it, please remove all the superfluous files: rm -f *_output_output.xml
 
i'll do that right away. but I've tried it with no loop, i ran what i have just posted to the update all the way at the bottom, and still there was nothing written to output, is what i posted there what you had in mind?
 
8:44 AM
Hi there.
 
hi. maybe i need to get rid of the .xml i think
in the basename
 
No, that's perfectly fine.
 
ah cool, i've never been in a chat on here before
 
Ya me too, first time.
 
thank you for helping me out with this by the way
 
8:44 AM
So, I was saying... (my pleasure)
when you run the command just as a single one ,
without the loop, do you get the output as nonempty?
 
no still empty
 
Does that mean that your command itself is at fault?
 
i don't think so becasue the command generates output as normal, as if something were going on. oh wait! let me try it w/o piping the output, then i can see, hold on a sec
 
Sure.
 
hmm, that didn't work, i think becasue of $g and $f and the program got confused i think
 
8:48 AM
No, did you type the actual filenames in the command, and did it work?
forget g and f for the moment.
 
oh yeah, that works
 
Just take one literal filename.
Ah ok.
So then the loop should work!
So, let's do one experiment... just type the command:
f=your_file_name.xml
I mean the input file name.
And then say:
g="$(basename $f .xml)_output.xml"
and then
g="$(basename $f .xml)_output.xml"
sorry, I mean
echo "$g"
(no need to do the assignment two times, my mistake)
 
yeah that works perfectly
hmm, neat trick, i need to remember that
 
Ah. Then I don't know sitting here, what's wrong with the output!
I would say just cross check whether you have typed the command correctly in the script..
Any luck?
 
ahhhh!!! eureka!
it works!
 
8:57 AM
Ah. Not empty?
 
no indeed
 
So what was the problem?
 
i have no idea
 
:)
 
i was trying originally with the script you first wrote
but what worked was the one you put lately
which avoids the _output.xml files
 
8:58 AM
With skipping. That was the only change.
Perhaps you were looking at one of the output_output.xml files, which were empty.
 
yeah, that could be it
 
Hmmm. Now you can remove those extra ones by
 
or it was getting overwritten by an empty output ouput file or something
 
rm -f *_output_output.xml
 
yeah, absolutely top-ranked man, that's fokken brilliant
 
8:59 AM
that's not possible. if the names are different, then the contents don't get mixed.
 
how did you know about that? you read up on bash?
 
Thanks... One favour.
 
yeah certainly
 
You can accept the answer.
 
oh yeah, of course
 
9:00 AM
Ah, I have been bashing for some eight years now.
May be more. Was a sysadmin for five years.
 
did you read a book on it or just cobble together your knowledge from different online tid bits and the like
 
So this much anyone on stackoverflow would be able to say!
Well, the best source is on your system:
man bash
 
but technical documentation is so damn dry,
 
Read it fully, except may be the "readline" section.
 
alright i'll do that.
 
9:02 AM
Hmmm. I like to learn that way. One does not try to remember everything,
but definitely read everything.
Then when the time is right ( I mean when you have a problem),
 
yeah, thatls good advice
 
you remember that there was something like this in the manual.
And then you go back and look it up.
 
i'll read it today
 
Glad it helped.
 
actually what i do recently is text to speach software and just listen to it on high speed
 
9:03 AM
Wow.
can you tell me more?
I mean what you do is real stuff! Bash is just the surface!
 
yeah, sure i use either 'chrome speak' or soemthing called 'speakit!'
no i mean to read stuff
i don't actually read anyhting anymore
 
Ah. I thought you are working on text to speech conversion!
 
haha i wish
 
:)
 
but actually, not so different
i'm working on nlp things these days
that's what i was working with, that stanford nlp library
 
9:05 AM
wow.
Was that other question also from you?
 
i guess, i post many questions
but its really a fast way to learn i think
 
I mean about parsing some content within xml file?
 
mmm, maybe. not xml, i wrote one the other day about .pb files
 
Ah no. That was someone else.
Hmmm. I am talking about:
1
Q: Edit XML node with linguistic parsing - Java

SophieMI hope someone can help me: first of all, I'm still a newbie with Java, but slowly improving, I guess. So, I have an XML file with linguistic annotations and I would like to access a specific node to a) perform a pattern-matching operation on it and b) perform further operations on the matches ...

So I thought it was you. But just checked.
The title does not say it,
but it is about NLP.
 
hmm, that wasn't me but actually i'll read that too, i think it's related to seomthing i'm working on
 
9:09 AM
There is a grammatically marked sentence in it,
hmm. yes
Anyway.. nice talking to you.
 
yes, likewise
hope to see you on here again.
 
And there is one more person listening to us. Hello to him/her too.
 
ah!
the nsa you mean?
 
It shows as tivn
On my screen, on the right, in the chatroom description,
there are three people.
you, me, and tivn.
 
huh, i dont see that. funny.
 
9:11 AM
Ok! anyway.. see you!
 
right-o
take care.
 
9:30 AM
@S.Matthew_English Are you around?
 
10:11 AM
hi, sorry i went to go drink some milk
 
 
2 hours later…
11:44 AM
hey, are you still here?
 

last day (14 days later) »