Sponsored Content
Top Forums Shell Programming and Scripting sed, awk [TAG]$content[/TAG] How to get var in $content in textfile? Post 302401097 by czk on Friday 5th of March 2010 01:11:20 AM
Old 03-05-2010
Quote:
Originally Posted by atmosroll
Thx for the replies! But if the content is for example:

Code:
nfotext="$(cat "$nfo")"


and in text file looks like this:

[nfo]$nfotext[/nfo]

How do i get the nfo content between the nfo tags?
try something like this (assuming here that you are replacing the literal string "$nfotext")


Code:
#!/bin/bash

TAGS="nfo1 nfo2 nfo3 nfo4"

nfo1var="text for nfo1"
nfo2var="text for nfo2"
nfo3var="text for nfo3"
nfo4var="text for nfo4"

cmdfile=./cmds.sed
echo "#commands to insert data between tags" > $cmdfile

for i in $TAGS; do
    eval REP="\$${i}var"
    echo "s/\(\$${i}text\)/"$REP"/ " >> $cmdfile
done

sed -f "$cmdfile" infile.dat > outfile.dat

easy to change this so you don't need a cmds.sed file...
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read a file content with awk and sed

Hello , I have huge file with below content. I need to read the numeric values with in the paranthesis after = sign. Please help me with awk and sed script for it. 11.10.2009 04:02:47 Customer login not found: identifier=(0748502889) prefix=(TEL) serviceCode=(). 11.10.2009 04:03:12... (13 Replies)
Discussion started by: rmv
13 Replies

2. Shell Programming and Scripting

changing files content with sed or awk

Hi, Example File: (jumped, bumped, ) how to jumped, FROM tree; EXIT I have some hundreads of files like this with the different words and I want to remove the comma before the bracket and also I have to remove the comma before FROM word. I am trying to use this command : awk '... (5 Replies)
Discussion started by: rajshashi
5 Replies

3. Shell Programming and Scripting

How to retrieve the value from XML tag whose end tag is in next line

Hi All, Find the following code: <Universal>D38x82j1JJ </Universal> I want to retrieve the value of <Universal> tag as below: Please help me. (3 Replies)
Discussion started by: mjavalkar
3 Replies

4. HP-UX

XML tag name content replacement

Hi, Need to replace an XML tag name contents, please provide any suggestions. Scenario is : <abc_def>Value_some_content</abc_def> Expected output : <abc:def>Value_some_content</abc:def> We have many tag with different names & contents in a file or a string. Please help on the... (3 Replies)
Discussion started by: periyasamycse
3 Replies

5. Shell Programming and Scripting

Search for a html tag and print the entire tag

I want to print from <fruits> to </fruits> tag which have <fruit> as mango. Also i want both <fruits> and </fruits> in output. Please help eg. <fruits> <fruit id="111">mango<fruit> . another 20 lines . </fruits> (3 Replies)
Discussion started by: Ashik409
3 Replies

6. Shell Programming and Scripting

XML Parse between to tag with upper tag

Hi Guys Here is my Input : <?xml version="1.0" encoding="UTF-8"?> <xn:MeContext id="01736"> <xn:VsDataContainer id="01736"> <xn:attributes> <xn:vsDataType>vsDataMeContext</xn:vsDataType> ... (12 Replies)
Discussion started by: pareshkp
12 Replies

7. Shell Programming and Scripting

To search for a particular tag in xml and collate all similar tag values and display them count

I want to basically do the below thing. Suppose there is a tag called object1. I want to display an output for all similar tag values under heading of Object 1 and the count of the xmls. Please help File: <xml><object1>house</object1><object2>child</object2>... (9 Replies)
Discussion started by: srkmish
9 Replies

8. Shell Programming and Scripting

Moving XML tag/contents after specific XML tag within same file

Hi Forum. I have an XML file with the following requirement to move the <AdditionalAccountHolders> tag and its content right after the <accountHolderName> tag within the same file but I'm not sure how to accomplish this through a Unix script. Any feedback will be greatly appreciated. ... (19 Replies)
Discussion started by: pchang
19 Replies

9. Shell Programming and Scripting

find files in sub dir with tag & add "." at the beginning [tag -f "Note" . | xargs -0 {} mv {} .{}]

I am trying find files in sub dir with certain tags using tag command, and add the period to the beginning. I can't use chflags hidden {} cause it doesn't add period to the beginning of the string for web purpose. So far with my knowledge, I only know mdfind or tag can be used to search files with... (6 Replies)
Discussion started by: Nexeu
6 Replies
NFORENUM(1)						    BSD General Commands Manual 					       NFORENUM(1)

NAME
NFORenum -- A tool for checking NFO code for errors, and for beautifying that code SYNOPSIS
nforenum [options] [file [file2 [file3 [...]]]] OPTIONS
--auto-correct | -a Perform some rudimentary automatic correction of incorrect pseudo sprites. This may be specified twice to enable the corrections that are more likely to be incorrect. See the README for detailed information on the auto-correcter. --comments=type | -c type <type> is one character, either /, ;, or #, and specifies the comment style that NFORenum will use. This will not change the header, because grfcodec requires that the header be commented in C++-style. --data[=dir] | -D[dir] If <dir> is specified, look for the .nforenum directory in <dir>, and create it if not found. If <dir> is not specified, report the location of the .nforenum directory. In either case, eliminate the 5-second wait used to ensure that those not running NFORenum from a command line can see the directory-created message. Default: Look for the .nforenum directory in the current directory, and then in the environment variable HOME, if defined. If not found attempt to create in HOME, then in . --force | -f Forces processing of files that do not look like NFO files. The default is to treat such files as if they specified a too-high info version. --help | -h Display the help message. --lock Locks the current comment command state. Commands will continue to be parsed as normal (so NOPRESERVE will be honored, @@DIFF will be removed, &c.) but their changes (such as turning on the diff-assister) will not be honored. --no-replace | --keep-old | -k Do not replace the old NFO file; write new file to file.new.nfo. Default: Use file[.nfo].new as temporary, rename it to file[.nfo] when done. --silent | -s Silence the progress output in interactive mode. --version | -v Display the version. --write-data Refresh all data files, unless they are newer. The following options cause NFORenum to behave as if all files started with the associated command. The readme has full details on the com- ment commands. Options associated with comment commands that require additional information take that information as an argument. With the exception of -L/--let, the options to the command line versions are case insensitive. "ON" and "OFF" may be specified with "+" and "-", respectively. --beautify | -b @@BEAUTIFY --diff | -d @@DIFF --let | -L @@LET --lint | -l @@LINT --preserve-messages | -p @@PRESERVEMESSAGES --real-sprites | -r @@REALSPRITES --use-old-nums | -o @@USEOLDSPRITENUMS --warning-disable | -w @@WARNING DISABLE --warning-enable | -W @@WARNING ENABLE -w and -W (and their long counterparts) also accept a comma-separated list of messages, all of which will be ENABLEd or DISABLEd. SEE ALSO
The documentation in /usr/share/doc/nforenum/ AUTHOR
nforenum was written by Dale McCoy, with portions by Dan Masek, Thijs Marinussen, Remko Bijker and Christoph Elsenhans. This manual page was written by Remko Bijker. August 05, 2010
All times are GMT -4. The time now is 12:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy