03-21-2013
Finding row number along with length of row
I have a fixed length file and I want to find out row number along with row length.
I have a program that give me the line length if it satisfy the condition; but i would like to add row number as well?
How do I do that?
HTML Code:
while IFS= read -r line; do
if [ ${#line} == 4499 ]; then
echo ${line}
echo ${#line}
echo "You have access!thereis a line length of 4499"
fi
done < input.dat
Thanks ,
Prince
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I want to write a shell script which increments a particular column in a row from a text file and then adds another row below the current row with the incremented value .
For Eg .
if the input file has a row :
abc xyz lmn 89 lm nk o p
I would like the script to create something like... (9 Replies)
Discussion started by: aYankeeFan
9 Replies
2. UNIX for Advanced & Expert Users
Using Linux and Bash, I have a script that outputs filenames with complete path, like this:I would like the following output:And I would like to get the filenames only. Tricky part is that I cannot predict how many levels deep the filename is located, so I cannot use standard Bash-kungfu to solve... (7 Replies)
Discussion started by: indo1144
7 Replies
3. Shell Programming and Scripting
hi all,
I use shell script to fetch some data's from my sybase database and i redirect my output to a file , i have some disorder in my file.my current o/p file looks like,
firstrecord|secondrecord|thirdrecord|fourthrecord|fivthrecord|s
ixhrecord|seventhrecord|
... (10 Replies)
Discussion started by: ulin
10 Replies
4. Shell Programming and Scripting
Hi.
How can we print those rows of file2 which are mentioned in file1. first character of file1 is a row number.. for eg
file1
1:abc
3:ghi
6:pqr
file2
a abc
b def
c ghi
d jkl
e mno
f pqr
... (6 Replies)
Discussion started by: Abhiraj Singh
6 Replies
5. Shell Programming and Scripting
Hi. How can I read row number from one file and print that corresponding record present at that row in another file.
eg
file1
1
3
5
7
9
file2
11111
22222
33333
44444
55555
66666
77777
88888
99999 (3 Replies)
Discussion started by: Abhiraj Singh
3 Replies
6. Shell Programming and Scripting
HI Guys,
I have Below Input :-
RepigA_hteis522 ReptCfiEtrBsCll_aofe
MSL04_MSL2_A25_1A 0 9
MSL04_MSL2_A25_1B 0 9
MSL04_MSL2_A25_1C 0 9
RepigA ReptCfiEtrBsCll
hteis522 aofe
MSL04_MSL2_A25_1A 0 9
MSL04_MSL2_A25_1B 0 9
MSL04_MSL2_A25_1C 0 9
Split Data in two first row... (2 Replies)
Discussion started by: pareshkp
2 Replies
7. Shell Programming and Scripting
Hi guys,
i have a csv file like:
USERID;COG;DESCR;FIL;OFF
user001;user;test1;001;A01
user002;user;test2;002;A02
user0003;user;test3;003;A03
user004;user;test4;004;A04
user0005;user;test5;005;A05
etc..
I need to read line for line and, if value of first column is > 7 char (in this example... (4 Replies)
Discussion started by: kamose
4 Replies
8. UNIX for Beginners Questions & Answers
My original files are like this below and I distinguish them from the AP_ID (file1 has 572 and file2 has 544). Also, the header on file1 has “G_” pre-pended. NOTE: these are only snippets of very large files and much of the data is not present here.
Original File 1:
... (36 Replies)
Discussion started by: aachave1
36 Replies
9. Shell Programming and Scripting
Hi ALL,
We have requirement in a file, i have multiple rows.
Example below:
Input file rows
01,1,102319,0,0,70,26,U,1,331,000000113200000011920000001212
01,1,102319,0,1,80,20,U,1,241,00000059420000006021
I need my output file should be as mentioned below. Last field should split for... (4 Replies)
Discussion started by: kotra
4 Replies
10. UNIX for Beginners Questions & Answers
This is a question that is related to one I had last August when I was trying to sort/merge two files by millsecond time column (in this case column 6).
The script (below) that helped me last august by RudiC solved the puzzle of sorting/merging two files by time, except it gets lost when the... (0 Replies)
Discussion started by: aachave1
0 Replies
LEARN ABOUT PHP
ovrimos_fetch_into
OVRIMOS_FETCH_INTO(3) OVRIMOS_FETCH_INTO(3)
ovrimos_fetch_into - Fetches a row from the result set
SYNOPSIS
bool ovrimos_fetch_into (int $result_id, array &$result_array, [string $how], [int $rownumber])
DESCRIPTION
Fetches a row from the given result set, into $result_array.
PARAMETERS
o $result_id
- A result identifier, returned by ovrimos_execute(3) or ovrimos_exec(3).
o $result_array
- You must provide an array by reference. It will be filled with the fetched values.
o $how
- Determines how the rows are fetched. This can be one of the following strings (case is not significant):
+---------+---------------------------------------------------+
| Option | |
| | |
| | Notes |
| | |
+---------+---------------------------------------------------+
| | |
| Next | |
| | |
| | Forward direction from current position. This is |
| | the default value. |
| | |
| | |
| Prev | |
| | |
| | Backward direction from current position. |
| | |
| | |
| First | |
| | |
| | Forward direction from the start. |
| | |
| | |
| Last | |
| | |
| | Backward direction from the end. |
| | |
| | |
|Absolute | |
| | |
| | Absolute position from the start. Requires |
| | $rownumber. |
| | |
+---------+---------------------------------------------------+
o $rownumber
- The row number, first one is 0. Only needed when $how is set to Absolute.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
A fetch into example
<?php
$conn=ovrimos_connect("neptune", "8001", "admin", "password");
if ($conn!=0) {
echo "Connection ok!";
$res=ovrimos_exec($conn, "select table_id, table_name from sys.tables");
if ($res != 0) {
echo "Statement ok!";
if (ovrimos_fetch_into($res, $row)) {
list($table_id, $table_name) = $row;
echo "table_id=" . $table_id . ", table_name=" . $table_name . "
";
if (ovrimos_fetch_into($res, $row)) {
list($table_id, $table_name) = $row;
echo "table_id=" . $table_id . ", table_name=" . $table_name . "
";
} else {
echo "Next: error
";
}
} else {
echo "First: error
";
}
ovrimos_free_result($res);
}
ovrimos_close($conn);
}
?>
SEE ALSO
ovrimos_fetch_row(3).
PHP Documentation Group OVRIMOS_FETCH_INTO(3)