04-03-2006
problem with new line
Hi Masters,
Here is the code someone posted days ago, but it didn't work well because it did't omit the newline character when $2 conbines. Can someone help me out?
awk '{if($1==prev) printf(" /// "$2); else {printf("\n"$1" " $2);prev=$1}}'
Basically, this code is trying to remove the redundent line in a two column spreadsheet file based on the field one, but merge field 2 if field one is redundent.
Thanks in advance.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi all,
I've searched the web and this forum for this but not had any luck. I'm trying to use sed so when it finds a space it will insert a new line.
What i have is a file containing .e.g
1 2 4 7 9
and want it to look like
1
2
4
7
9
I've tried:
more test2 | sed 's/ /\\n/g'... (1 Reply)
Discussion started by: Cordially
1 Replies
2. Shell Programming and Scripting
Hi all!
I have a problem with line command. The aim is to write each line of stdin into a text file.
For example with this command:
$find /
/usr/share/zoneinfo/WET
/usr/share/zoneinfo/Zulu
/usr/share/zoneinfo/iso3166.tab
/usr/share/zoneinfo/localtime
/usr/share/zoneinfo/zone.tab... (3 Replies)
Discussion started by: victorin
3 Replies
3. Shell Programming and Scripting
Hi everyone. I realise this is probably a bit of a noob question, but I'm actually a C# developer working on a legacy system, and can't remember much unix.
I want to read from a pipe-delimeted file like formatted thusly:
idno|PRODUCT|Name|street town postcode|etc|etc|etc|etc... (4 Replies)
Discussion started by: Darkness Fish
4 Replies
4. Shell Programming and Scripting
At first, give my best wish for all MOD and admins here. I"m learning bash shell program just for a month, not too much, not too little, but i must admire that i'm very bad at math and algorithm. :(
I want to do this :
Read the content of a file line by line and at each line, ask me want to... (3 Replies)
Discussion started by: madi3d8
3 Replies
5. Shell Programming and Scripting
So, I want to read line-by-line a text file with unknown number of files....
So:
a=1
b=1
while ; do
b=`sed -n '$ap' test`
a=`expr $a + 1`
$here do something with b etc
done
the problem is that sed does not seem to recognise the $a, even when trying
sed -n ' $a p'
So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies
6. Shell Programming and Scripting
Hi everybody, I am new to shell script. Please help me with this problem.
I have a file test.txt with the content like this:
I have a shell script test.sh like this
#!/bin/sh
while read line
do
echo $line >> out.txt
done < test.txt
out.txt is expected to have the same content... (10 Replies)
Discussion started by: Dark2Bright
10 Replies
7. Shell Programming and Scripting
hi ,
i need to check the first line of a tilde(~) delimitted source file, so i wrote a command as follows
head -1 <source filename>
but the problem is that the line is too lengthy,as it spans out of the window,so im not able to see the line till end.can anybody please suggest a workaround... (2 Replies)
Discussion started by: angel12345
2 Replies
8. Shell Programming and Scripting
Hi folks,
I've list of LDAP records in this format:
cat cmmac.export.tmp2
dn: deviceId=0a92746a54tbmd34b05758900131136a506,ou=devices,ou=customer,ou=nl,o=upc
cmmac: 00:13:11:36:a5:06
dn: deviceId=0a92746a62pbms4662299650015961cfa23,ou=devices,ou=customer,ou=nl,o=upc
cmmac:... (4 Replies)
Discussion started by: tomas.polak
4 Replies
9. Shell Programming and Scripting
Hi All,
Please can you advise/help on the below issue
i did a bcp out of a table, it is having problem of line break such that one line is getting broken in two lines for many records.
eg
Correct format
Line 1: - 000f00000bfe2c2c 000218310300000000GBP GBP 734654 10970.35 ... (3 Replies)
Discussion started by: mad_man12
3 Replies
10. UNIX for Dummies Questions & Answers
i have a file like below
New_file.txt
123|345|ab cd|ef gh
345|456|jk hu|uyh
My script is
#!/bin/ksh
set -x
for line in `cat New_file.txt`
do
a1=`echo $line|cut -d '|' -f1`
echo $a1
done
output
++ cat New_file.txt (2 Replies)
Discussion started by: Rajesh_us
2 Replies
LEARN ABOUT PHP
cubrid_field_seek
CUBRID_FIELD_SEEK(3) 1 CUBRID_FIELD_SEEK(3)
cubrid_field_seek - Move the result set cursor to the specified field offset
SYNOPSIS
bool cubrid_field_seek (resource $result, [int $field_offset])
DESCRIPTION
This function moves the result set cursor to the specified field offset. This offset is used by cubrid_fetch_field(3) if it doesn't
include a field offset. It returns TRUE on success or FALSE on failure.
PARAMETERS
o $result
-$result comes from a call to cubrid_execute(3)
o $field_offset
- The numerical field offset. The $field_offset starts at 0. If $field_offset does not exist, an error of level E_WARNING is also
issued.
RETURN VALUES
TRUE on success.
FALSE on failure.
EXAMPLES
Example #1
cubrid_field_seek(3) example
<?php
$conn = cubrid_connect("localhost", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT event_code,athlete_code,nation_code,game_date FROM game WHERE host_year=1988 and event_code=20001;");
var_dump(cubrid_fetch_row($req));
cubrid_field_seek($req, 1);
$field = cubrid_fetch_field($req);
printf("
--- Field Properties ---
");
printf("%-30s %s
", "name:", $field->name);
printf("%-30s %s
", "table:", $field->table);
printf("%-30s "%s"
", "default value:", $field->def);
printf("%-30s %d
", "max length:", $field->max_length);
printf("%-30s %d
", "not null:", $field->not_null);
printf("%-30s %d
", "unique key:", $field->unique_key);
printf("%-30s %d
", "multiple key:", $field->multiple_key);
printf("%-30s %d
", "numeric:", $field->numeric);
printf("%-30s %s
", "type:", $field->type);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
The above example will output:
array(4) {
[0]=>
string(5) "20001"
[1]=>
string(5) "16132"
[2]=>
string(3) "KOR"
[3]=>
string(9) "1988-09-30"
}
--- Field Properties ---
name: athlete_code
table: game
default value: ""
max length: 0
not null: 1
unique key: 1
multiple key: 0
numeric: 1
type: integer
PHP Documentation Group CUBRID_FIELD_SEEK(3)