I have a couple structure definitions in my input code. For example:
or
I used the following line to convert them into one line and copy it twice.
The result is this:
This is what I want:
I want sed commands that takes an input file that contains those lines(repeating struct definitions) and does the following.
I would like the first line to be restored to the original structure block
I would like the second line to turn into to a function heading that looks like this...
-structName is basically the name of the structure.
-var is any name you like.
-data1, data2.... are values that are in the struct.
3. I would like the third line to turn into to the function body. Where I initialize the the data parameters. It would look like this.
So my input initially consists of struct definitions. After running the sed command shown above, all of them are converted into one line and copied twice.
This is the input we need to work with. So when the code finds a structure defintion it can assume that there will be two more copies below.
For example, this is the output I want if the input file had the repeating lines shown above(node and rational).
In case someone was curious. These functions will be called from the main to initialize the struct variables.
If you want clarification please ask, I will respond quickly!!
Can someone help? Thanks so much!!
-James D
Last edited by James Denton; 09-23-2012 at 07:44 PM..
I read in two numbers from a user but the number is a string.
#!/bin/bash
read -p "Enter first number: " num1
read -p "Enter second number: " num2
I know you can use the the "expr" or "bc" command to automatically convert the string to a number then add them together. But I don't want to add... (10 Replies)
I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios.
Cat test
Nov 10, 2012 5:17:53 AM
INFO: Request Type
Line 1.... (5 Replies)
here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb
cat dump.sql
INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Hi.
I will be very appreciated for help.
I need replace all characters into string with \ (backslash)
I mean if I have word abcdefg as input.
How I can convert it to \a\b\c\d\e\f\g
Thanks and best regards. Staas. (5 Replies)
Hi Guys,
is there any command to convert the output returned by the below command to string format:
Code:
sed 1!d filename
Output is :
108
---------- Post updated at 11:03 AM ---------- Previous update was at 11:00 AM ----------
Because i am using this output as string parameter ... (4 Replies)
i have this piece of small code that checks for *.CSV files.
NUMFILES=`ls -1 *.CSV | wc -l`
for filename in $(ls -1 *.CSV)
do
...
done
it works only if the files has an uppercase of *.CSV extension. however, when there is a file of the same type but has lowercase *.csv... (1 Reply)
Hi
I have a line/string as follows:
A=" 3498 NORDEA - INDX LINKED NORY"
which was converted into an array of characters:
p321$ echo "${ARR}"
3 4 9 8 N O R D E A - I N D X L I N K E D N O R Y
When I am trying print this array there are blank... (4 Replies)
Hi,
i want to read a text file whose content(single line) will be a number like 1 or 2 or 3 ..... what i want to do is to read the file and increment the content of the file, using unix scripting.
Regards,
Senthil Kumar Siddhan. (2 Replies)
Hi,
I have read some figures from a text file by getting the position and wish to do some checking, but it seem like it won't work.
eg. my figure is 0.68 it still go the the else statement,
it seems like it treat it as a text instead of number.
Anybody can Help ? Thanks.
# only... (3 Replies)