Hi -
Have file1 which has the below date
And also have file2 which has the below texts
I need to read the second file if it has colon (:) then move the date from first file to second file
like this
have used cut -d":" -f1 and moved the value ASOF: into a variable but not able to find the length and move the date value. Can somebody help me please.
Moderator's Comments:
Please use CODE tags when displaying sample input, sample output, and code segments as required by forum rules.
Hi -
Have file1 which has the below date
And also have file2 which has the below texts
I need to read the second file if it has colon (:) then move the date from first file to second file
like this
have used cut -d":" -f1 and moved the value ASOF: into a variable but not able to find the length and move the date value. Can somebody help me please.
Moderator's Comments:
Please use CODE tags when displaying sample input, sample output, and code segments as required by forum rules.
Your requirements are ambiguous as to whether or not there is anything in file1 other than the date and, if there is, where in that file the date is located; whether or not there might be more than one line containing a colon in file2; and, if there is more than one line containing a colon, whether or not all lines containing a colon should be modified. And, again, you have not told us what operating system and shell you're using.
Assuming that the date in file1 is alone on the first line in that file (and not caring whether or not there might be other lines in that file), that you only want to change lines in file2 that contain the string ASOF: and that all (zero or more) lines containing that string should be modified, and that you're using a shell that is based on Bourne shell syntax, then you might want to try something like:
This User Gave Thanks to Don Cragun For This Post:
Hello All,
I am trying to get the value "node01_mymachine" and disregard the rest of the returned string (command ran*) from myscript.sh
$ myscript.sh GetNodeName
node01_mymachine
Command ran successfully.
If I called from another script like this:
anyprocess=`myscript.sh... (2 Replies)
Sorry for setting my foot as just a technical user on holy ground here again asking and learning. After tries with strings and arrays I decided to go for an if-else-if-ladder for a database, just because it looks a little easier to me, but as it happens, my result is not the desired one.
So here... (8 Replies)
Hi All
I have written code for storing data in a string based on pattern.
whenever i tried to use in a function call its not getting there.
Actually the same logic was applied for another string..then i can use the
string at any function.
the code goes like this
/mp metadata/{... (1 Reply)
Hello,
I am recently working on an application that sends large strings accross a network very often. These then need to be broken up first with '!' and then with ','. My current function (below) works fine for this when not too much data is being sent across the network but segfaults when a... (4 Replies)
Can I create a function to return non-interger value in shell script?
for example,
function getcommand ()
{
echo "read command"
read command
echo $command
}
command=$(getcommand)
I tried to do something as above. The statement echo "read command" does not show up.
... (5 Replies)
Hi
I have a shell function which returns string(ksh). The string is an sql statement.
This statement can have '*' in its content (i.e. select 100 / 2 *100 from dual).
When this happens ret_str will have contents of current directry I run the script from build in sql. Is there any way to fix it... (2 Replies)
I need to pass a parameter to a function in a script. My parameter is a string. When I display the parameter within my function, I only get the first word from string I pass in.
How can I make the function receive the whole string (and not terminate at the first space it encounters)?.
part of... (1 Reply)
I have two string returning function in ESQL/C
char *segment_name(lbuffer)
char *lbuffer;
{.....
and
char *get_bpdvalue(f_name)
char *f_name;
{......
both declared above main()
char *get_bpdvalue();
char *segment_name();
my problem is segment_name works on sprintf and strcpy... (5 Replies)
I have a question concerning string functions. I have not been able to locate a function that does what I want, so I fugured I'd ask before I wrote on myself.
Is there a function to which I can pass 2 strings (character string a and character string b) and have it tell me if string b appears... (7 Replies)