Sponsored Content
Top Forums Shell Programming and Scripting Script to add backslashes to end of certain lines of text Post 302762527 by icskittles on Monday 28th of January 2013 04:00:21 PM
Old 01-28-2013
Script to add backslashes to end of certain lines of text

I'd like to write up notes in a relatively readable format and then use a shell script to add LaTeX formatting. Specifically, I'm trying to figure out how to add the LaTeX newline character (\\) to the end of lines without \begin{} or \end{} statements

example notes file:
\begin{enumerate}
-- first note
\begin{itemize}
-- first sub-note that spans multiple lines
so new line characters would be really nice
otherwise this gets a bit hard to read
-- second sub-note
\end{itemize}
(lather, rise, repeat)
\end{enumerate}

So far I am using sed to change -- to \item and then using a LaTeX wrapper file to add header info and pdf it:
Code:
#!/bin/sh
# inputs: $1 - input notes file name (txt file)
#            $2 - output file name (pdf)

sed 's:--:\\item:g' $1 > tmpNotes.tex
# Need code to add \\ to end of text lines!

sed 's:INPUTFILE:tmpNotes.tex:' wrapper.tex > tmpWrapper.tex
pdflatex -nonstopmode tmpWrapper.tex 
mv tmpWrapper.pdf $2.pdf

Can someone tell me how to add \\ to only the text lines (that is, all lines without \begin{} or \end{})?
Thanks!
 

10 More Discussions You Might Find Interesting

1. HP-UX

Add a column at the end of all the lines in a file

Hi Guys, :D I am very much new to UNIX. I dont have much basics of coding in UNIX, so please help me out of thi ssituation. I have a file say for ex: ABC.dtd and it contains "|" delimited data as test1|testing|test3|moving past1|runing|test4|going I need to add a column at the end... (6 Replies)
Discussion started by: ruthless
6 Replies

2. Shell Programming and Scripting

add text to end of text file

Hi, I assume there is a simple solution, but as usual i can't find it! How can i add a line of text to the end of a text file on a new line? i.e file.txt ________________ this is my text file ________________ file.txt ________________ this is my text file WITH A NEW LINE... (6 Replies)
Discussion started by: leeRoberts2007
6 Replies

3. Shell Programming and Scripting

adding text to the end of lines containing a word

I'm new to shell scripting, and need to add a series of commands to the ends of certain lines of text that contain a keyword. Any easy way to do this? Thanks (2 Replies)
Discussion started by: ironwall
2 Replies

4. Shell Programming and Scripting

print string at the end of lines in text file

hello, I go text file like this E:/DDD/Dyndede/wwww E:/DDD/sss.com/ffffg/fff E:/DDD/vvvvvv/dd E:/DDD/sss.com/bbbbbb E:/DDD/sss.com/nnnn/xxI want to print /alpha.jpg at the end of every lines like that E:/DDD/Dyndede/wwww/alpha.jpg E:/DDD/sss.com/ffffg/fff/alpha.jpg... (8 Replies)
Discussion started by: davidkhan
8 Replies

5. Shell Programming and Scripting

Append text to end of line on all lines

Hi, I've spent some time researching for this but can't seem to find a solution. I have a file like this 1234|Test|20101111|18:00|19:00There will be multiple lines in the file with the same kind of format. For every line I need to make it this 1234|Test|20101111|18:00|19:00||create... (5 Replies)
Discussion started by: giles.cardew
5 Replies

6. UNIX for Dummies Questions & Answers

Removing trailing lines at the end of a text file

How do you remove trailing empty lines at the end of a text file? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies

7. UNIX for Dummies Questions & Answers

Add strings from one file at the end of specific lines in text file

Hello All, this is my first post so I don't know if I am doing this right. I would like to append entries from a series of strings (contained in a text file) consecutively at the end of specifically labeled lines in another file. As an example: - the file that contains the values to be... (3 Replies)
Discussion started by: gus74
3 Replies

8. UNIX for Dummies Questions & Answers

Search a file for certain strings and add them to the end of certain lines

I have a log file which lists groups and users in the following format GROUP1 user1 user2 user3 GROUP2 user4 user5 user6 GROUP3 user7 user8 I need to change the format to: user1|GROUP1 user2|GROUP1 user3|GROUP1 user4|GROUP2 (3 Replies)
Discussion started by: Angela S
3 Replies

9. Shell Programming and Scripting

Add text to the end of line

Seems simple but ive been searching for a good hour of so I have a text file and would like to add a string to the end of line 5 ( as an example) to ake tings hard the line number we have to add the text to is stored in a variable cunningly name $Line_to_append any ideas on how this could... (2 Replies)
Discussion started by: dunryc
2 Replies

10. Shell Programming and Scripting

Selecting text on multiple lines, then removing a beginning and end patterns

I have a file similar to the below. I am selecting only the paragraphs with @inlineifset. I am using the following command sed '/@inlineifset/,/^ *$/!d; s/@inlineifset{mrg, @btpar{@//' $flnm >> $ofln This produces @section Correlations between seismograms,,,,}} ... (5 Replies)
Discussion started by: Danette
5 Replies
SGML2LATEX(1)						      General Commands Manual						     SGML2LATEX(1)

NAME
sgml2latex - create LaTeX, DVI, PostScript or PDF output from a LinuxDoc DTD SGML source file SYNOPSIS
sgml2latex [generic-option...] [--output=tex|dvi|ps|pdf] [--bibtex] [--makeindex] [--pagenumber=n] --quick [--latex=hlatexp|platex] [--dvips=dvips|dvi2ps] file[.sgml] DESCRIPTION
sgml2latex is an old and obsoleted form of the latex converter command of LinuxDoc-Tools. It is recommended to switch the new form linux- doc -B latex now. It converts a LinuxDoc DTD SGML source file to LaTeX output, using the nsgmls(1) or onsgmls(1) parser, and the sgml- sasp(1) translator. Using the LaTeX output, and the latex(1) text formatter, you can then create DVI output, and PostScript output using the dvips(1) converter. Output will appear in file.tex for LaTeX output, file.dvi for DVI output, or file.ps for PostScript output, where file is the name of the SGML source file. Using the LaTeX output, and the pdflatex(1) text formatter, you can then create a nice PDF output, suitable for viewing with PDF viewers as xpdf(1), acroread(1) or ghostview(1). The attribute/value pair "output=latex2e" is set for conditionals. OPTIONS
sgml2latex accepts all the generic options described in linuxdoc(1), and the following specific options: --output=fmt, -o Specify the desired output format. The specifier fmt may be ``tex'', ``dvi'', ``ps'', or ``pdf''. Note: This version does not overwrite/remove the intermediate files: tex file for dvi output, or tex/dvi files for ps output. This is dif- ferent behavior from the original SGML-Tools 1.0.9, so you are warned here. --bibtex, -b Process the generated TeX with bibtex(1). --makeindex, -m Generate a TeX index file suitable for processing with makeindex(1) from and <idx> and <cdx> tags present in the SGML source. --pagenumber, -n Set the starting page number in the output DVI or PS file. --quick, -q Do only one pass of LaTeX formatting. This is often not sufficient to produce final output (because of references, etc.) but is useful for spotting TeX errors and justification problems. --pass, -P The argument of the pass option is inserted just after the LaTeX preamble generated by the document-type tag. Specify the desired output format. The specifier fmt may be ``tex'', ``dvi'', ``ps'', or ``pdf''. --latex=alternate_latex_command, -x This option is currently for Korean and Japanese. The alternate_latex_command can be ``latex'' (default), ``hlatexp'' (for Korean), ``platex'' or ``jlatex'' (for Japanese). This option can be used to render Korean document using HLaTeXp, or to render Japanese document using pLaTeX/jLaTeX. If not, HLaTeX should be installed to render Korean document. On the other hand, Japanese document can be rendered with jLaTeX (which is the default when ``-c nippon'' is specified), so if you already have jLaTeX, you may not need to install the pLaTeX. --dvips=alternate_dvips_command, -s This option is currently for Japanese. The alternate_dvips_command can be ``dvips'' or ``dvi2ps''. If you don't know this, then you may not need this. file The SGML source file, named either file or file.sgml FILES
Many files and executables in /usr/share/linuxdoc-tools and /usr/bin are used. BUGS
None known. AUTHOR
Originally written by Greg Hankins <greg.hankins@cc.gatech.edu>, based on scripts by Tom Gordon and Alexander Horz. Later rewritten by Cees de Groot <cg@cdegroot.com>. PDF patches by Juan Jose Amor <jjamor@hispalinux.es>. Currently maintained by Taketoshi Sano <sano@debian.org> for Linuxdoc-Tools. SEE ALSO
linuxdoc(1), sgml2html(1), sgml2info(1), sgml2lyx(1), sgml2rtf(1), sgml2txt(1), sgmlcheck(1). 18 May 2000 SGML2LATEX(1)
All times are GMT -4. The time now is 07:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy