Sponsored Content
Full Discussion: Reduce redundant file
Top Forums Shell Programming and Scripting Reduce redundant file Post 302969298 by giuliangiuseppe on Monday 21st of March 2016 08:36:33 AM
Old 03-21-2016
Reduce redundant file

Dear All,
I have to reduce the redundancy of a file that is like this:

Code:
a b 0
a c 0
a f 1
b a 1
b a 0
b c 1
d f 0 
g h 1
f d 1

Basically, this file describe a network with relative nodes and edges.
The nodes are the different letters and the edges are represented by the numbers (in particluar 0, means that the direction of edges is from left to right, 1 is viceversa).


As you may notice, some interaction are duplicates (in bold). For example interaction:

Code:
a b 0
b a 1

a-->b
b<--a

Are exactly the same. The first line interaction go from a to b (0 means inreaction go from left to right), in second line interaction still go from a to b (1 means interaction go from right to left).


What I would like is to filter the file above and output a file like this:

Code:
a b 0
a c 0
a f 1
b a 0
b c 1
d f 0 
g h 1

So, all the duplicated interaction are removed.
!Interactions

Code:
a b 0
b a 0

are not the same! Both go from left to right but is different the starting node.
a-->b
b-->a

Hope is clear.

Best

Giuliano
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

to check redundant file names

hi i have a very simple problem iam moving files from download to archive folder but before such a transfer want to make sure no two file of same are present in my download directory how to check for redundant file names i thought of using WC but it counts inside the file (lines and... (5 Replies)
Discussion started by: maverick
5 Replies

2. UNIX for Dummies Questions & Answers

Question is redundant but please advice

I am really really new to Unix. I'm lost with so many books around for different shell. I'm thinking of taking a course on Operating Systems but it contains a lot of Unix programming I think. For example, someone was talking about a "which" command. But I wasn't able to figure out what it does...... (10 Replies)
Discussion started by: Legend986
10 Replies

3. Shell Programming and Scripting

How to reduce font size in a file

HPUX 11iv2 #!/bin/sh Hi all. I have a script that results in the creation of an ascii file which is ultimately emailed out to several people. The email wraps each line so I would like to reduce the font size of the ascii file. I looked at nroff and also tr but it wasn't clear to me how to do... (2 Replies)
Discussion started by: lyoncc
2 Replies

4. Shell Programming and Scripting

command to reduce size of file/directory???

Hello, I want to compress any given file or directory. I used 1)gzip 2)zip But when I do "ls -l". I found that the zipped file is in fact greater in size than the original file. Can you please tell me the commands which will show me the difference in its size. (2 Replies)
Discussion started by: nsharath
2 Replies

5. Shell Programming and Scripting

how to reduce a length in a file?

i want to reduce a length in the file called text in the file im having 10 byte length. want to reduce it to 9 byte length for all lines. (5 Replies)
Discussion started by: laknar
5 Replies

6. Filesystems, Disks and Memory

ZFS Raidz not redundant?

My ZFS on debian media server just died in a power outage, the zpool status shows this: NAME STATE READ WRITE CKSUM tank UNAVAIL 0 0 0 insufficient replicas raidz1 UNAVAIL 0 0 0 corrupted data sda ONLINE 0 0 0 sdb ONLINE 0 0 0 sdf ONLINE 0 0 0 sdh ONLINE 0 0 0 sdi ONLINE 0 0 0 sdk ONLINE 0... (2 Replies)
Discussion started by: mastersarg
2 Replies

7. Shell Programming and Scripting

How to reduce the length of records in a file?

I have a file with 400 characters How can I create another file with only a portion of them (like 300 within 400) and get rid of the rest? Thanks (5 Replies)
Discussion started by: fafchi
5 Replies

8. Shell Programming and Scripting

reduce pdf file size through multiple folders

Dear all, i have a lot of .pdf files that i need to reduce size with pdf2ps and ps2pdf app. I need a script which i can reduce file size of all .pdf files in every subfolder of WORKDIR folder. folder tree like: WORKDIR SUBBWORK DIR1 SUB_SUB_WORKDIR1 ... (1 Reply)
Discussion started by: migor78
1 Replies

9. Shell Programming and Scripting

Find redundant text in a file

I want to find which pattern or strings have occurred more than one time so that I can remove unnecessary redundancy. For example: If I have the sentence: A quick brown brown fox jumps jumps jumps over the lazy dog in a file, then I want to know that 1. the word "brown" has... (7 Replies)
Discussion started by: hbar
7 Replies

10. AIX

AIX flag to reduce size of shared file

I am using xlC (Version: 11.01.0000.0011). While build i am using "-g" to have debug information in build. there are many object files (>500) due to which resultant shared file (.so) will have huge size. I can't reduce optimization level. Is there any way or flag is present by using which i... (2 Replies)
Discussion started by: Abhi04
2 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 10:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy