10-24-2007
removing a delimiter at the start of row
I Have this code
while [ ${iCount1} -le ${reccount} ]
do
column1=":`cat /home/test_inter.txt|head -${iCount1}|tail -1|cut -d "," -f2`"
columnA=$columnA$column1
iCount1=`expr ${iCount1} + 1`
done
echo $columnA
The output of this code is coming as
:1:2:2:3:3:4
A colon(
at the beginning of each row I am using this colon as a field delimiter. But I don't want it at the beginning of each row.
Any help regarding this?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a file with millions of rows that I need to add a delimiter and a new field with a zero to the end of each row. (its too big to open and do a find and replace regex)
I'm looking for the next line '\n' and need to replace it with a Unit Separator (hex \037) 0 \n.
I've tried the... (2 Replies)
Discussion started by: kmac
2 Replies
2. Shell Programming and Scripting
Hello!
I have 32000 files in a directory and want to remove those with first row beging with 0.00; file names are in numbers from 1 through 32000; I have coded the following but it gives me error:
while ( i <= 32000 )
if (head -1 $i ==0.00) rm $i
end
Well, i am sure even if this... (14 Replies)
Discussion started by: nxp
14 Replies
3. Shell Programming and Scripting
HI,
i have a file like this
t.txt
f1|_f2|_
f1|_f2|_
f1|_f2|_
as if col delimiter is |_ and row delimiter |_\n
trying to count number of records using awk
$ awk 'BEGIN{FS="|_" ; RS="~~\n"} {n++}END{print n} ' t.txt
7
wondering how can i count this to 3 ?
thx (9 Replies)
Discussion started by: aksforum
9 Replies
4. Shell Programming and Scripting
Hi, i have data in a file f1.txt
a
b
c
d
and i want to print the above column values in single line with a delimiter, say ','
The output should look like:
a,b,c,d
I could find rows to columns help online but not vice versa
Thanks,
-srinivas yelamanchili (4 Replies)
Discussion started by: ysrini
4 Replies
5. Shell Programming and Scripting
i have input in below form
part=gfjhwhedaqh=ghdgwg^*^(G==
i want to remove the starting "part=" and retain the remaining. please suggest (4 Replies)
Discussion started by: skyineyes
4 Replies
6. Shell Programming and Scripting
Dear All,
We have input like this:
161 57 1378 176 1392 262 1444 441 1548 538 1611 670 1684
241 57 1378 208 1393 269 1447 444 1549 538 1610 677 1700
321 ... (4 Replies)
Discussion started by: attila
4 Replies
7. Shell Programming and Scripting
Hi,
I have tried to remove dublicate lines based on first column with pipe delimiter . but i ma not able to get some uniqu lines
Command : sort -t'|' -nuk1 file.txt
Input :
38376KZ|09/25/15|1.057
38376KZ|09/25/15|1.057
02006YB|09/25/15|0.859
12593PS|09/25/15|2.803... (2 Replies)
Discussion started by: parithi06
2 Replies
8. Shell Programming and Scripting
I have a file which looks something as following, I would like to split to several files, The start and end of each file is 'FILE' and end with 'ASCII... ' .
At the same time for each file in the first column add 100 and also second column add 100 the rest of the column as it is , see example of... (2 Replies)
Discussion started by: tk2000
2 Replies
9. Shell Programming and Scripting
Hi
I want to check delimiter in file. Delimiter in my file is ~|*
sample of file :
ABC~|*edgf~|*T1J333~|*20121130
ABC~|*sdaf~|*T1J333~|*20121130
ABC~|*fsdg~|*T1J333~|*20121130
ABC~|*dfsg~|*T1J333~|*20121130
in this i want to count number delimiter occur is 4 in each row if count is... (21 Replies)
Discussion started by: MOHANP12
21 Replies
10. Shell Programming and Scripting
I have a huge file (around 4-5 GB containing 20 million rows) which has text like:
<EOFD>11<EOFD>22<EORD>2<EOFD>2222<EOFD>3333<EORD>3<EOFD>44<EOFD>55<EORD>66<EOFD>888<EOFD>9999<EORD>
Actually above is an extracted file from a Sql Server with each field delimited by <EOFD> and each row ends... (8 Replies)
Discussion started by: amvip
8 Replies
LEARN ABOUT PHP
pg_fetch_assoc
PG_FETCH_ASSOC(3) PG_FETCH_ASSOC(3)
pg_fetch_assoc - Fetch a row as an associative array
SYNOPSIS
array pg_fetch_assoc (resource $result, [int $row])
DESCRIPTION
pg_fetch_assoc(3) returns an associative array that corresponds to the fetched row (records).
pg_fetch_assoc(3) is equivalent to calling pg_fetch_array(3) with PGSQL_ASSOC as the optional third parameter. It only returns an associa-
tive array. If you need the numeric indices, use pg_fetch_row(3).
Note
This function sets NULL fields to the PHP NULL value.
pg_fetch_assoc(3) is NOT significantly slower than using pg_fetch_row(3), and is significantly easier to use.
PARAMETERS
o $result
- PostgreSQL query result resource, returned by pg_query(3), pg_query_params(3) or pg_execute(3) (among others).
o $row
- Row number in result to fetch. Rows are numbered from 0 upwards. If omitted or NULL, the next row is fetched.
RETURN VALUES
An array indexed associatively (by field name). Each value in the array is represented as a string. Database NULL values are returned as
NULL.
FALSE is returned if $row exceeds the number of rows in the set, there are no more rows, or on any other error.
EXAMPLES
Example #1
pg_fetch_assoc(3) example
<?php
$conn = pg_connect("dbname=publisher");
if (!$conn) {
echo "An error occurred.
";
exit;
}
$result = pg_query($conn, "SELECT id, author, email FROM authors");
if (!$result) {
echo "An error occurred.
";
exit;
}
while ($row = pg_fetch_assoc($result)) {
echo $row['id'];
echo $row['author'];
echo $row['email'];
}
?>
SEE ALSO
pg_fetch_row(3), pg_fetch_array(3), pg_fetch_object(3), pg_fetch_result(3).
PHP Documentation Group PG_FETCH_ASSOC(3)