Sponsored Content
Top Forums Shell Programming and Scripting Replace last character of every second line Post 302462542 by malandisa on Thursday 14th of October 2010 12:16:51 PM
Old 10-14-2010
Replace last character of every second line

Hi all.

I wonder if this possible.... any help advice is very much appreciated..

I n a shell script I create a latex file that looks like this

\documentclass{article}
\usepackage{graphics}
\begin{document}
\begin{figure}
\begin{center}
\begin{tabular}{cc}

\resizebox{60mm}{!}{\includegraphics{e20011730124.eps}} &
\resizebox{60mm}{!}{\includegraphics{e20011730225.eps}} &
\resizebox{60mm}{!}{\includegraphics{e20011730326.eps}} &
\resizebox{60mm}{!}{\includegraphics{e20011730428.eps}} &
\resizebox{60mm}{!}{\includegraphics{e20011730529.eps}} &
\resizebox{60mm}{!}{\includegraphics{e20011730631.eps}} &
\resizebox{60mm}{!}{\includegraphics{e20011730732.eps}} &
\resizebox{60mm}{!}{\includegraphics{e20011730834.eps}} &
\resizebox{60mm}{!}{\includegraphics{e20011730935.eps}} &
\resizebox{60mm}{!}{\includegraphics{e20011731036.eps}} &


\end{tabular}
\caption{This is sample figures.}
\label{test4}
\end{center}
\end{figure}
\end{document}

Now I want to change this file so that it looks like as shown below. The highlighted part, I change every second line to replace the '&' by the '\\' chanracter

\documentclass{article}
\usepackage{graphics}
\begin{document}
\begin{figure}
\begin{center}
\begin{tabular}{cc}

\resizebox{60mm}{!}{\includegraphics{e20011730124.eps}} &
\resizebox{60mm}{!}{\includegraphics{e20011730225.eps}} \\
\resizebox{60mm}{!}{\includegraphics{e20011730326.eps}} &
\resizebox{60mm}{!}{\includegraphics{e20011730428.eps}} \\
\resizebox{60mm}{!}{\includegraphics{e20011730529.eps}} &
\resizebox{60mm}{!}{\includegraphics{e20011730631.eps}} \\
\resizebox{60mm}{!}{\includegraphics{e20011730732.eps}} &
\resizebox{60mm}{!}{\includegraphics{e20011730834.eps}} \\
\resizebox{60mm}{!}{\includegraphics{e20011730935.eps}} &
\resizebox{60mm}{!}{\includegraphics{e20011731036.eps}} \\


\end{tabular}
\caption{This is sample figures.}
\label{test4}
\end{center}
\end{figure}
\end{document}


Any one has an idea please help!
Malandisa
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace a character in last line

Hello Sed Experts, I have got a file which contain entries as below pmNoOfSwDownHsCong, pmUlUpswitchAttemptHigh, pmUlUpswitchAttemptLow, pmUlUpswitchSuccessHigh, pmUlUpswitchSuccessLow, pmUpswitchFachHsAttempt, ... (6 Replies)
Discussion started by: Mohammed
6 Replies

2. Shell Programming and Scripting

to replace a new line character

sample I/p: S12J LLL H77K PPP J25O LOP I73S lOP K99O PLO Required O/p: S12J LLL H77K PPP J25O LOP I73S lOP K99O PLO how to replace a new line character with space using sed command only Cheers, Chan (2 Replies)
Discussion started by: chan
2 Replies

3. Shell Programming and Scripting

Replace certain character with a new a new line.

Hello all... please help with the following. I am parsing the following type of file... W001; W003; W025;W044; W030; W022;W024;W099;W098; Would like to make it look like this... W001 W003 W025 W044 W030 W022 W024 W099 W098 (8 Replies)
Discussion started by: djsal
8 Replies

4. Shell Programming and Scripting

replace > with new line character

<reward_data><date><datetime>071308000804</datetime></date> I want the above data to be displayed as <reward_data> <date> <datetime>071308000804</datetime> </date> How can i accomplish this. I tried the below tr "><" ">\n" < filename (4 Replies)
Discussion started by: borncrazy
4 Replies

5. UNIX for Dummies Questions & Answers

match a character in a line and replace

Hi, I have a file with large number of records. Sample below: 123456789QWERT2U 2 erter 987123678ZXCVB6Y 5 7689 934567123GHJKUI4O 7 - -- -- I want the 16th character in each record to be replaced with the below as follows;so 2 will become K, 6 will become O and 4 will become... (3 Replies)
Discussion started by: er_ashu
3 Replies

6. Shell Programming and Scripting

how to replace character in the line

I have unix text file which has the following data aadjdfad;fa;fjjd;lakd;lkaslkd;k;k;lk;k;lk;l;lk;lkj;lj;lkj;k;lkj;lj;lkj;lkj;lkj;j sdkadk;adlf;lajf;akdjf;lkdjf;lkadjf;lkajsd;lfkj;lkj;lkj;lk;lk;lk;lk;k;lkj;k;lkm... (2 Replies)
Discussion started by: Raju Datla
2 Replies

7. Shell Programming and Scripting

How to replace all after 4th character in line ?

How to replace all after 4 character at line? & convert to upper case ? google.com -> GOOG (2 Replies)
Discussion started by: Trump
2 Replies

8. Solaris

Line too long error Replace string with new line line character

I get a file which has all its content in a single row. The file contains xml data containing 3000 records, but all in a single row, making it difficult for Unix to Process the file. I decided to insert a new line character at all occurrences of a particular string in this file (say replacing... (4 Replies)
Discussion started by: ducati
4 Replies

9. Shell Programming and Scripting

Replace x-y character in line

I have a file which has n number of lines, i want to replace 3rd line position 3-5 to some text. 111111111111111111 222222222222222222 333333333333333333 444444444444444444 expected output 111111111111111111 222222222222222222 33abc3333333333333 444444444444444444 it is... (7 Replies)
Discussion started by: greenworld123
7 Replies

10. Shell Programming and Scripting

Replace Control M (^M) character with new line

Hi All, We are getting an external file in abc.csv format. When opened in excel spread sheet, it is opening alright. But when opened in notepad, I see the contents in a single line. Ftp'd the file in binary mode to AIX UNIX host. When opened, I see Control M (^M) characters in place of New Line... (16 Replies)
Discussion started by: njny
16 Replies
TEXEXPAND(1)						User Contributed Perl Documentation					      TEXEXPAND(1)

NAME
texexpand - expand input and include statements in a TeX file DESCRIPTION
General translation mechanism: The main program latex2html calls texexpand with the document name in order to expand some of its input and include statements, here also called 'merging', and to write a list of sensitized style, class, input, or include file names. When texexpand has finished, all is contained in one file, TMP_foo. (assumed foo.tex is the name of the document to translate). In this version, texexpand cares for following environments that may span include files / section boundaries: a) egin{comment} b) %begin{comment} c) egin{any} introduced with excludecomment d) %begin{any} e) egin{verbatim} f) egin{latexonly} g) %begin{latexonly} e) - g) prevent texexpand from expanding input files, but the environment content goes fully into the output file. Together with each merging of input etc. there are so-called %%%texexpand markers accompanying the boundary. When latex2html reads in the output file, it uses these markers to write each part to a separate file, and process them further. Detailed technical notes: 1. %begin{latexonly} and %end{latexonly} have to be on a separate line. Anything between these tags (including the tags) is discarded. 2. egin{latexonly} and end{latexonly} have to be on a separate line. Anything between these tags (including the tags) is not expanded. 3. [%]begin{"to exclude"} and [%]end{"to exclude"} have to be on a separate line. Anything between these tags (including the tags) is discarded. 4. egin{verbatim/verbatim*} and end{verbatim/verbatim*} have to be on a separate line. Anything between these tags (including the tags) is not expanded. 5. The scope of any such tags may extend over several files. The opening tag for latexonly may occur on a different include level than the closing tag. The opening tag for verbatim/"to exclude" must occur within the same file than the closing tag. 6. Warnings are printed when the document has been parsed and open tags remain. 7. When in a "to exclude"/verbatim environment, texexpand won't recognize ANY command except the corresponding closing tag. There cannot be any nested constructions. This behaviour is identical to that of LaTeX. 8. egin{latexonly},end{latexonly} may be nested, whereas %begin{latexonly},%end{latexonly} may not be nested. 9. A "%" tag cannot close a "" tag, and vice versa. 10. Every document(class|style), usepackage, input and include command has to be on a separate line. 11. Everything behind a `%' that isn't preceded by a `' is regarded as a comment, i.e. it is printed but not interpreted. 12. If any command listed in 10. is preceded by an occurence of `verb' or `latex' then it is NOT interpreted. This crashes on lines like this: blah blah verb+foo foo+ input{bar} % bar won't be loaded! 13. Packages provided via usepackage are handled the same way as `options' in document(class|style), i.e. they are included when -auto_exclude is off, the package isn't in @dont_include *OR* the package is in @do_include (new). They are added to the style file together with their options if the file itself hasn't been merged. documentclass[options]{class} searches for every option.clo, documentstyle[options]{style} searches for every option.sty. usepackage[options]{packages} searches for every package.sty. 14. Each texinputs directory is searched for input files/styles. If it ends in `//', the whole subdirectory tree is searched. 15. input / include merge the given file (if found under the given name or with .tex extension) if its basename is in @do_include or if it isn't in @dont_include or if the given filename doesn't end in .sty/.clo/.cls when -auto_exclude is set. Notes Recognizes documentclass, documentstyle, usepackage, RequirePackage, egin{verbatim}...end{verbatim}, %begin{latexonly}...%end{latexonly}, egin{latexonly}...end{latexonly}, input, include, verb, latex endinput, end{document} includecomment, excludecomment egin{"to exclude"}, end{"to exclude"} %begin{"to exclude"}, %end{"to exclude"} The gory Details Include and parse a file. This routine is recursive, see also &process_input_include_file, &process_document_header, and &process_package_cmd. Two global flags control the states of texexpand. o $active is true if we should interprete the lines to expand files, check for packages, etc. o $mute is true if we should prevent the lines from going into the out file. We have three general states of texexpand: 1) interprete the lines and pass them to the out file This is the normal case. Corresponding: $active true, $mute false 2) interprete minimal and suppress them This is when parsing inside a comment environment, which also would retain its body from LaTeX. => $active false, $mute true 3) interprete minimal and pass the lines to the out file This is inside a verbatim or latexonly environment. The line of course must be at least interpreted to determine the closing tag. => $active false, $mute false Any environment may extend over several include files. Any environement except verbatim and latexonly may have its opening or closing tag on different input levels. The comment and verbatim environments cannot be nested, as is with LaTeX. We must at least parse verbatim/comment environments in latexonly environments, to catch fake latexonly tags. The work scheme: Five functions influence texexpand's behavior. o &process_file opens the given file and parses the non-comment part in order to set $active and $mute (see above). It calls &interprete to interprete the non-comment content and either continues with the next line of its file or terminates if &interprete detected the end{document} or an endinput. o &interprete handles some LaTeX tags with respect to the three states controlled by $active and $mute. Regarding to input|include, document(class|style), and (use|Require)package the functions &process_input_include_file, &process_document_header, and &process_package_cmd are called respectively. o These three functions check if the file name or option files are enabled or disabled for merging (via TEXE_DO_INCLUDE or TEXE_DONT_INCLUDE). Any file that is to include will be 'merged' into the current file, i.e. the function &process_file is called at this place in time (recursively). This will stop interpretation at the current line in file, start with the new file to process and continues with the next line as soon as the new file is interpreted to its end. The call tree (noweb+xy.sty would be handy here): main | v +->process_file | | | v | interprete (with respect to the current line, one of that three) | | | | | v v v | process_input_include_file process_document_header process_package_cmd | | | | | v v v +----+---------------------------+------------------------+ Bugs: o Since the latexonly environment is not parsed, its contents might introduce environments which are not recognized. o The closing tag for latexonly is not found if hidden inside an input file. o One environment tag per line, yet! o If I would have to design test cases for this beast I would immediately desintegrate into a logic cloud. Notes: o Ok, I designed test cases for it. Please refer to test 'expand' of the regression test suite in the developers' module of the l2h repository. o -unsegment feature: In this (rare) case, the user wants to translate a segmented document not in segments but in a whole (for testing, say). We enable this by recognizing the segment command in &interprete, causing the segment file to be treated like input but loosing the first lines prior to startdocument (incl.), as controlled via $segmentfile. On how to segment a document you are best guided by section ``Document Segmentation'' of the LaTeX2HTML manual. CAVEATS
This utility is automatically configured and built to work on the local setup. If this setup changes (e.g. some of the external commands are moved), the script has be be reconfigured. Authors Based on texexpand by Robert Thau, MIT AI lab, including modifications by Franz Vojik <vojik@de.tu-muenchen.informatik> Nikos Drakos <nikos@cbl.leeds.ac.uk> Sebastian Rahtz <spqr@uk.ac.tex.ftp> Maximilian Ott <max@com.nec.nj.ccrl> Martin Boyer Herbert Swan Jens Lippmann 3rd Berkeley Distribution perl 5.005, patch 03 TEXEXPAND(1)
All times are GMT -4. The time now is 10:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy