Sponsored Content
Operating Systems Linux SuSE finding and removing block of identical strings Post 302522685 by cocostaec on Monday 16th of May 2011 10:14:31 AM
Old 05-16-2011
finding and removing block of identical strings

i have a problem in finding block of identical strings...i solved the problem in finding consecutive identical words and now i want to expand the code in order to find and remove consecutive identical block of strings...
for example the awk code removing consecutive identical word is:
Code:
#!/usr/bin/awk -f
BEGIN{
RS="[[:space:]]+";
ORS=""
}
match($0,/^([[:punct:]]*)([^[:punct:]]+)([[:punct:]]*)$/,f){
if(x != f[2])
{
print y$0;z = FNR
}
x = f[2];
y = RT
}
END{
if(z != FNR)
print f[3]"\n"
}

input:
Code:
"ana are mere mere
mere si portocale
ion are prune prune."

output:
Code:
"ana are mere si portocale
ion are prune."

and now i want to expand the code to do the following:
input:
Code:
"ana are ana are mere
ion are prune ion are prune"

output:
Code:
"ana are mere
ion are prune"

thanks

Last edited by cocostaec; 05-16-2011 at 12:01 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replace 2 identical strings on different lines

I am looking to replace two or more strings on different lines using sed, but not with the same variable. IE # cat xxx.file <abc> abc def ghi abc def ghi abc def ghi currently I can only change each line with the same pattern: # sed -e '/<abc>/!s/abc\(.*\)/jkl mno/' xxx.file abc jkl mno... (3 Replies)
Discussion started by: prkfriryce
3 Replies

2. Shell Programming and Scripting

count identical strings print last row and count

I have a sorted file like: Apple 3 Apple 5 Apple 8 Banana 2 Banana 3 Grape 31 Orange 7 Orange 13 I'd like to search $1 and if $1 is not the same as $1 in the previous row print that row and print the number of times $1 was found. so the output would look like: Apple 8 3 Banana... (2 Replies)
Discussion started by: dcfargo
2 Replies

3. Shell Programming and Scripting

Removing identical words in column

I have a file that needs to be cleaned up. Here is the file: Project Project John Project Gary Project Sean Project2 Project2 Lisa Project2 Tyler Project2 Sam Project3 Project3 Mike Project3 Bran I need the o/p to be: Project John Gary Sean Project2 (7 Replies)
Discussion started by: leepet01
7 Replies

4. Shell Programming and Scripting

Finding strings

Hi I made a post earlier but now my problem has become a lot more complicated. So I have a file that looks like this: Name 1 13 94 1 AGGTT Name 1 31 44 1 TTCCG Name 1 13 94 2 AAAAATTTT Name 1 41 47 2 GGGGGGGGGGG So the file is tab delimited and what I want to do is find... (8 Replies)
Discussion started by: kylle345
8 Replies

5. Shell Programming and Scripting

Using Bash/Sed to delete between identical strings

Hi. I'm hoping that someone can help me with a bash script to delete a block of lines from a file. What I want to do is delete every line between two stings that are the same, including the line the first string is on but not the second. (Marked lines to match with !) For example if I... (2 Replies)
Discussion started by: Zykr
2 Replies

6. Shell Programming and Scripting

finding and removing 2 identical consecutive words in a text

i want to write a shell script that correct a text file.for example if i have the input file: "john has has 2 apples anne has 3 oranges oranges" i want that the output file be like this: "john has 2 apples anne has 3 oranges" i've tried to read line by line from input text file into array... (11 Replies)
Discussion started by: cocostaec
11 Replies

7. Programming

finding and removing block of identical strings

i have a problem in finding block of identical strings...i solved the problem in finding consecutive identical words and now i want to expand the code in order to find and remove consecutive identical block of strings... for example the awk code removing consecutive identical word is:... (2 Replies)
Discussion started by: cocostaec
2 Replies

8. Shell Programming and Scripting

finding and removing block of identical strings

i have a problem in finding block of identical strings...i solved the problem in finding consecutive identical words and now i want to expand the code in order to find and remove consecutive identical block of strings... for example the awk code removing consecutive identical word is:... (2 Replies)
Discussion started by: cocostaec
2 Replies

9. Ubuntu

Merging strings that have identical rownames in a dataframe

Hi I have a data frame with repeated names in column 1, and different descriptors in column 2. I want to merge/cat strings that have same entry in column 1 into one row with any separator. Example for input: Cvel_1 KOG0155 Cvel_1 KOG0306 Cvel_1 KOG3259 Cvel_1 ... (4 Replies)
Discussion started by: Alyaa
4 Replies

10. Shell Programming and Scripting

Print text between 2 identical strings

hey, i m having a hard time trying to print only the first occurrence between 2 idenicale strings. for the following output: please help me im a noob please im a noob help me noob please help me im a noob please im a noob help me noob (3 Replies)
Discussion started by: boaz733
3 Replies
creat64(2)							System Calls Manual							creat64(2)

NAME
creat64(), fstat64(), fstatvfs64(), getrlimit64(), lockf64(), lseek64(), lstat64(), mmap64(), open64(), pread64(), prealloc64(), pwrite64(), setrlimit64(), stat64(), statvfs64(), truncate64(), ftruncate64(), O_LARGEFILE - non-POSIX standard API interfaces to support large files SYNOPSIS
DESCRIPTION
New API's to support large files in 32-bit applications. These API interfaces are not a part of the POSIX standard and may be removed in the future. The function returns a file descriptor which can be used to grow the file past 2 GB if desired. All other functional behaviors, returns, and errors are identical to The function is identical to except that returns file status in a instead of a All other functional behaviors, returns, and errors are identical. The function is indentical to except that returns file status in a struct instead of a struct The function is identical to except that passes a as its second parameter instead of a All other functional behaviors, returns, and errors are identical. The function is identical to except that accepts an for the size parameter instead of All other functional behaviors, returns, and errors are identical. The function is identical to except that accepts an type as the desired offset and has a return value of All other functional behaviors, returns, and errors are identical. The function is identical to except that returns file status in a instead of All other functional behaviors, returns, and errors are identical. The function is identical to except that accepts the file offset as an The function opens files of any size. It returns a file descriptor which can be used to grow the file past 2 GB if desired. All other functional behaviors, returns, and errors are identical to The function is identical to except that accepts the file offset as an All other functional behaviors, returns, and errors are identical to The function is identical to except that accepts the file offset as an All other functional behaviors, returns, and errors are identical to The function is identical to except that accepts the file offset as an All other functional behaviors, returns, and errors are identical to The function is identical to except that passes a as its second parameter instead of a All other functional behaviors, returns, and errors are identical. The function is identical to except that returns file status in a instead of a Refer to The function is identical to except that accepts the length parameter as an instead of All other functional behaviors, returns, and errors are identical to The function is identical to except that accepts the length parameter as an instead of All other functional behaviors, returns, and errors are identical to Setting in a call to or is equivalent to calling or both of which set in the file status flags. This bit is automatically set by and if is set to 64. The bit may be queried by (or which can also turn the bit on or off if desired. APPLICATION USAGE
The standard POSIX interfaces may be used by 32-bit applications to create and access large files if compiled with set to 64. The interfaces described here are alternatives to the standard ones, and are enabled by defining For 64-bit applications, access to large files is automatic, as long as the underlying file system is enabled for large files. The inter- faces on this man page are available to 64-bit applications, for convenience in porting, but provide no additional capabilities. The exception is which is not visible to 64-bit applications. SEE ALSO
creat(2), thread_safety(5). creat64(2)
All times are GMT -4. The time now is 11:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy