04-25-2007
Hi all,
Thanks for all the answers..based on the above answers I modified the below script ..
Here is the input file...
XYZ-2066779% xyz~%
XYZ-000036480% chxyz36r~%
XYZ-2056453% abder~000082685%
XYZ-3038583% fulfil302~00026%
I need to extract the first part before '%' and the second part after '~' and before '%'
so my output must be
XYZ-2066779
XYZ-000036480
XYZ-2056453 000082685
XYZ-3038583 00026
The script is:
while read LINE
do
NEWC_ID=`echo $LINE | awk -F'%' '{print toupper($1)}'`
NEWF_ID=`echo $LINE | awk -F'%' '{print ($2)}'`
NF_ID=`echo $NEWF_ID | sed s/\'/\'\'/g`
C_ID=`echo $NEWC_ID | sed s/\'/\'\'/g`
F_ID=`echo $NF_ID | awk -F'~' '{print ($2)}'`
echo $C_ID
echo "-----"
echo $F_ID
echo "-----"
done < $loc/input.txt
Please let me know if there is a better way of implementing the above script..
Thanks in advance..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I need to extract the uncommon (better say incremental) part from 2 files say file_1 and file_2.
file_2 contains everything that is in file_1. That is file_2 has been created internally somehow :
cat file_1 temp_file > file_2
My objective is to extract the temp_file part from... (2 Replies)
Discussion started by: sabyasm
2 Replies
2. Shell Programming and Scripting
Hi,
I was wondering if there is an easy way to strip off the required basename. I have a script called apb0110021.sh and the contents of the script are
typeset -u MScript=`basename $0 | cut -d. -f1`
scriptname=sys.Audit.ksh
parms="PROJECT1 dsAudit $MScript 1 BEGIN"
$SCRIPTS/$scriptname... (3 Replies)
Discussion started by: madhunk
3 Replies
3. Shell Programming and Scripting
JADE TRADER 143W MYPEN 40 HC M X10 28 7 1 0
MYPEN 20 GP X X10 15 2 1 0
MYPEN 40 GP X X10 28 7 1 0
MYPEN 20... (6 Replies)
Discussion started by: finalight
6 Replies
4. Shell Programming and Scripting
Hi,
I am trying to extract part of a line using "awk". My requirement is to extract the value $6 (which is the last parameter) from a line. As the sixth value contains some space, i am getting only part of the string. so i am trying to extract from $6 to the end of the buffer.
How to do it... (7 Replies)
Discussion started by: venkat_k
7 Replies
5. Shell Programming and Scripting
Hi Guys,
I have a very large XML feed (2.7 MB) which crashes the server at the time of parsing. Now to reduce the load on the server I have a cron job running every 5 min.'s. This job will get the file from the feed host and keep it in the local machine.
This does not solve the problem as... (9 Replies)
Discussion started by: shridhard
9 Replies
6. Shell Programming and Scripting
Hi,
I have a file few hundred MB's with text like one below in single line.
20091117 abc xyg 20091117 def ghi 20091118 ppp ttt 20091118 zzz zzz xxx
I need to extract part of line from 1st occurence of pattern 20091117
till first occurence of another pattern 20091118.
I tried... (3 Replies)
Discussion started by: artistic94555
3 Replies
7. UNIX for Dummies Questions & Answers
I have the code
message={TP=2012:09:23:00:00:00:GMT,SD=2012:09:23:00:00:00:GMT,SP=2,FT=CCGT,FG=3605}
I want to extract the FG=3605 parts of this. Please help. I am trying to do this using awk or unix. (5 Replies)
Discussion started by: JenniferTopham
5 Replies
8. Shell Programming and Scripting
Hi,
I needed to extract some specific characters from a string based on user input. For example: After the script executes the user enters the following details:
Please enter the string: This is a shell script
Please enter the starting position: 11
Please enter the number of characters to be... (4 Replies)
Discussion started by: ChandanN
4 Replies
9. Shell Programming and Scripting
I have a string:
2015-04-16 07:30:05,625000 +0900 xxxx.com
I just want to extract the time from the above line I am using the below syntax
x=~ /(.*) (\d+)\:(\d+)\:(\d+),(.*)\.com/
$time = $2 . ':' . $3 . ':' . $4;
print $time
But it is not working. Can some1 please help (2 Replies)
Discussion started by: karan8810
2 Replies
10. Shell Programming and Scripting
Hi All,
I have log files as below.
log1.txt
<table name="content_analyzer" primary-key="id">
<type="global" />
</table>
<table name="content_analyzer2" primary-key="id">
<type="global" />
</table>
Time taken: 1.008 seconds
ID = gd54321bbvbvbcvb
<table name="content_analyzer"... (7 Replies)
Discussion started by: ROCK_PLSQL
7 Replies
LEARN ABOUT PHP
mssql_field_seek
MSSQL_FIELD_SEEK(3) MSSQL_FIELD_SEEK(3)
mssql_field_seek - Seeks to the specified field offset
SYNOPSIS
bool mssql_field_seek (resource $result, int $field_offset)
DESCRIPTION
Seeks to the specified field offset. If the next call to mssql_fetch_field(3) won't include a field offset, this field would be returned.
PARAMETERS
o $result
- The result resource that is being evaluated. This result comes from a call to mssql_query(3).
o $field_offset
- The field offset, starts at 0.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
Using mssql_field_seek(3) on the example for mssql_fetch_field(3)
<?php
// Connect to MSSQL and select the database
mssql_connect('MANGOSQLEXPRESS', 'sa', 'phpfi');
mssql_select_db('php');
// Send a select query to MSSQL
$query = mssql_query('SELECT * FROM [php].[dbo].[persons]');
// Construct table
echo '<h3>Table structure for 'persons'</h3>';
echo '<table border="1">';
// Table header
echo '<thead>';
echo '<tr>';
echo '<td>Field name</td>';
echo '<td>Data type</td>';
echo '<td>Max length</td>';
echo '</tr>';
echo '</thead>';
// Dump all fields
echo '<tbody>';
for ($i = 0; $i < mssql_num_fields($query); ++$i) {
// Fetch the field information, notice the
// field_offset parameter is not set. See
// the mssql_field_seek call below
$field = mssql_fetch_field($query);
// Print the row
echo '<tr>';
echo '<td>' . $field->name . '</td>';
echo '<td>' . strtoupper($field->type) . '</td>';
echo '<td>' . $field->max_length . '</td>';
echo '</tr>';
// Move the internal seek pointer to the next
// row in the result set
mssql_field_seek($query, $i + 1);
}
echo '</tbody>';
echo '</table>';
// Free the query result
mssql_free_result($query);
?>
SEE ALSO
mssql_fetch_field(3).
PHP Documentation Group MSSQL_FIELD_SEEK(3)