Hello all, the title makes this sound simple, and maybe it should be.
This is by code:
This is what I am trying to do. I have a file like this:
Quote:
First there was nothing. Then there was Calvin[1].
That contains a body of text with footnotes markers, that are of exactly that format [i]. Square brackets are not used otherwise in the text... at least no patters of the form [integer] exist except for footnote markers.
I have a another file of the footnote text, like this
Quote:
[1] A memorable quote from Bill Waterson's Calvin and Hobbes.
What that code I wrote is attempting to do is:
Create a copy of the body text to mess with.
Count the number of footnotes that exist.
Initiate a For loop that will generate an $i for every integer up to $n, the number of footnotes.
grep the line starting with [$i] and save stick it into a temp file.
use awk to grab only the text portion of the footnote (skipping the [$i] number at the beginning of the line) and store that in variable r.
Finally, search the main file for the [$i] marker and add the footnote, alone with \footnote{} markup for latex.
Repeat hundreds of times (-;
I am not all that great with scripting, but this is my thought process and what I have tried. Right now... nothing happens. I execute the script, and it just hangs, and I have to break the script.
In case you are wondering, I am just trying to typeset Marx's Das Kapital for posterity and easier reading. I do not plan on printing or distributing... just taking a freely available reading material and making it pretty.
PS, I notice that I forgot a semicolon after the for argument... I added that and it still does not run. Thank you!
PPS, I also realized that I should probably have back-ticked the grep and sed commands... but that also did not solve my problem.
PPPS, I am fixing the stupid errors in my code... I hope you don't decline to help me because they existed! lol
Last edited by ccox85; 05-11-2009 at 05:27 PM..
Reason: Updates... I am trying too!
Alright, so this was an uninteresting problem, I guess... no hits at all except for my own! But, I did solve PART of the problem, so for what its worth I am going to explain that... I am sure I am not the only person to make this mistake.
In my grep command, I was trying to reference a variable integer stored in $i.
Grep was reading the $ independently, as a regular expression meaning "at the end of the line" I think... but at any rate, it was NOT looking for the variable $i and passing that into the argument.
To work around this:
This works for the grep part... But I guess now the kink is in getting the for command to acknowledge the $n variable...
Now, the issue seems to be that it is dumping to standard output, rather than actually editing ch25.fn.tex. I dont really know why thats happening... and I THINK that it printed to stout 140 times, each with the footnote added to only that one number... I THINK that is what happened. To much output to sift through. I feel that I have narrowed down the problem to my sed command.
I have spent too much time playing around already. I hope someone finds this interesting or is sympathetic to my curiosity and helps me out!
Wow, that worked like a charm and was less elaborate than my scheme. It'll take me a bit to understand what you did, I don't know perl at all, but it certainly got the job done. Thank you!
Hi Everyone,
I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file.
I am very new to unix. Kindly help... (10 Replies)
HI
Can any one guide me how to achieve this task. I have 2 files
env.txt
#Configuration.Properties values
identity_server_url = http://identity.test-hit.com:9783/identity/service/user/register
randon_password_length = 6
attachment_file_path = /pass/temp/attachments/... (1 Reply)
I don't know if it's been asked before but seems i gave up seeking.
i have 2 files :
file1.txt
Monday XXXX
Tuesday XXXX
XXXX Wednesday
Thursday XXXX
XXXX is in every lines of file1.txt and i want to replace them with each line in file2.txt:
home
school
cinema
so output file is:
... (19 Replies)
Hi,
I want to achieve something similar to what described in another post:
The difference is I want to add the line if the pattern is not found.
File 1:
A123, valueA, valueB
B234, valueA, valueB
C345, valueA, valueB
D456, valueA, valueB
E567, valueA, valueB
F678, valueA, valueB
... (11 Replies)
Hi experts,
In my text file I have the following alot of lines like below.
input.k is as follows.
2684717 -194.7050476 64.2345581 150.6500092 0 0
2684718 -213.1575623 62.7032242 150.6500092 0 0
*INCLUDE
$# filename... (3 Replies)
Hi
I am not the best scripter in the world and have run into a issue which you might be able to guide me on...
I have two files.
File1 :
A123, valueA, valueB
B234, valueA, valueB
C345, valueA, valueB
D456, valueA, valueB
E567, valueA, valueB
F678, valueA, valueB
File2:
C345,... (5 Replies)
Can someone tell me how I can do this?
e.g:
Say file1.txt contains:
today is monday
the 22 of
NOVEMBER
2010
and file2.txt contains:
the
11th
month
of
How do i replace the word NOVEMBER with (5 Replies)
To trim 3rd field in for all the lines of a file and replace the modified string in that particular field.
For example i have a file called Temp.txt having content
Temp.txt
-----------------
100,234,M1234
400,234,K1734
300,345,T3456
----------------
So the modified file output should... (4 Replies)
Hi,
I want to replace the srting '; with ABCD'; in a file from line 1 to line 65. Is there any single command to do it without using awk
Thanks for quick reply
https://www.unix.com/images/misc/progress.gif (3 Replies)
i am very new to UNIX
plz help me in this scenario
i have two text files as below
file1.txt
name=Rajakumar.
Discipline=Electronics and communication.
Designation=software Engineer.
file2.txt
name=Kannan.
Discipline=Mechanical.
Designation=CADD Design Engineer.
... (6 Replies)