Handling XML isn't trivial. It's not one "thing", it's a lot of things.
How I'd suggest doing it is breaking down the tag into multiple lines so you can read "date=Trump Tue 06/19/2012 11:41 AM EDT", then "machine=garg-ln", etc, etc, until the tag is done. xargs can do that easily.
Then you read one by one, splitting on = or < or > into two variables, catch the names you want and ignore the rest.
I need a way to build variable in this manner:
variable_$i
Inside a for loop i need to create it.
where i goes from 1 to 30..
and then i need to print them on screen with echo $variable_$i
which is the best way to do this? (6 Replies)
Dear All,
I have a file with the syntax below (composed of several <log ..... </log> stanzas)
I need to search this file for a number e.g. 2348022225919, and if it is found in a stanza, copy the whole stanza/section (<log .... </log>) to another output file.
The numbers to search for are... (0 Replies)
Hi, guys. I have one question:
I need to search for a string in a file, and then extract another string from the file and assign it to a variable.
For example:
the contents of the file (group) is below:
...
ftp:x:23:
mail:x:34
...
testing:x:2001
sales:x:2002
development:x:2003
...... (6 Replies)
I tried awk for this, but failed <or my code is not correct? I dont know>. Can anyone help me on this?
---------- Post updated at 08:34 PM ---------- Previous update was at 08:29 PM ----------
my working file looks like this:
<empty>
<empty>
<empty>
NAME :ABC AGE :15
GENDER... (6 Replies)
Hello All,
How to concatenate a string to a variable in a script
I'm having a file which is consisting of data and i need to extract the first line of the file and append it to a string.
/tmp/samp.list containg 60000
I like to concatenate it with a string (SS_)
grep -w SS_$(head -1... (1 Reply)
hi,
In a given directory, i need to search for a string (eg:ABCD).
For a given file, i have to extract the text between START and END strings .
I need to extract all the text between START and END and there can be multiple START and END in a file.
Sample:
There is a directort... (3 Replies)
Hi guys,
I have a text file named file1.txt that is formatted like this:
001 , ID , 20000
002 , Name , Brandon
003 , Phone_Number , 616-234-1999
004 , SSNumber , 234-23-234
005 , Model , Toyota
007 , Engine ,V8
008 , GPS , OFF
and I have file2.txt formatted like this:
... (2 Replies)
Hi All,
I hope somebody would be able to help me.
I would need to search a string coming from a file, example file.txt:
dog
cat
goat
horse
fish
For every string, I would need to know if there are any files inside a directory(recursively) that contains the string regardless of case.... (9 Replies)
Discussion started by: kokoro
9 Replies
LEARN ABOUT ULTRIX
xstr
xstr(1) General Commands Manual xstr(1)Name
xstr - extract strings from C program
Syntax
xstr [-c] [-] [file]
Description
The command maintains a file strings into which strings in component parts of a large program are hashed. These strings are replaced with
references to this common area. This serves to implement shared constant strings, most useful if they are also read-only.
The command
xstr -c name
will extract the strings from the C source in name, replacing string references by expressions of the form (&xstr[number]) for some number.
An appropriate declaration of is prepended to the file. The resulting C text is placed in the file x.c, to then be compiled. The strings
from this file are placed in the strings data base if they are not there already. Repeated strings and strings which are suffices of
existing strings do not cause changes to the data base.
After all components of a large program have been compiled a file xs.c declaring the common space can be created by a command of the form
xstr
This xs.c file should then be compiled and loaded with the rest of the program. If possible, the array can be made read-only (shared) sav-
ing space and swap overhead.
The command can also be used on a single file. A command
xstr name
creates files x.c and xs.c as before, without using or affecting any strings file in the same directory.
It may be useful to run after the C preprocessor if any macro definitions yield strings or if there is conditional code which contains
strings which may not, in fact, be needed. The command reads from its standard input when the argument `-' is given. An appropriate com-
mand sequence for running after the C preprocessor is:
cc -E name.c | xstr -c -
cc -c x.c
mv x.o name.o
The command does not touch the file strings unless new items are added, thus can avoid remaking xs.o unless truly necessary.
Options
- Reads stdin.
-c Extracts strings from specified C source (next argument).
Restrictions
If a string is a suffix of another string in the data base, but the shorter string is seen first by both strings will be placed in the data
base, when just placing the longer one there will do.
Files
strings Data base of strings
x.c Massaged C source
xs.c C source for definition of array `xstr'
/tmp/xs* Temp file when `xstr name' doesn't touch strings
See Alsomkstr(1)xstr(1)