Sponsored Content
Top Forums Shell Programming and Scripting Help with if else with additional condition Post 302836297 by perl_beginner on Wednesday 24th of July 2013 02:17:44 AM
Old 07-24-2013
Help with if else with additional condition

Input file:
Code:
3420023_3422482,3422486_3423070 46910
1795263_1798343 32681
1837399_1838886 1534
2148674_2149696,2149698_2149772 10203
3825382_3825555,3827296_3827900 198
1839890_1840294 72
.
.

Output file
Code:
3420023_3422482,3422486_3423070 3420023_3422482,3422486_3423070 46910
1795263 1798343 32681
1837399 1838886 1534
2148674_2149696,2149698_2149772 2148674_2149696,2149698_2149772 10203
3825382_3825555,3827296_3827900 3825382_3825555,3827296_3827900 198
1839890 1840294 72
.
.

If column 1 have "_", I would like to change/replace the "_" into "\t" delimiter;
If column 1 have "_" and "," at the same time, I would like the desired output file have same data contents in column 1 and column 2;

Below is the command I try:
Code:
awk -F"_" '{print $1"\t"$2"\t"}' input_file
awk '$1~/,/{print $1"\t"$1"\t"$2"\t"}' input_file

I feel like the command I try is not really efficient to generate desired output file.
Thanks for any advice.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Additional character output

Hi there, I am just wondering if somebody can help me find out why am I getting additional characters on my "echo" command to create a text file. Here's my unix script : #!/bin/ksh #============================================================ # Script Name : chk_ORDHD.ksh # Description... (2 Replies)
Discussion started by: negixx
2 Replies

2. UNIX for Advanced & Expert Users

Help with Additional Password Features

Hello: I have a customer who is requesting the following security features on a Solaris 8 system: 1. Password history for the three previous passwords. 2. User account lockout after 3 failed login attempts. Can anyone help provide me with a solution or direction for the above? (1 Reply)
Discussion started by: rambo15
1 Replies

3. AIX

Install additional fonts ?

Hi, I have two fonts installed on my AIX machine: FONT FILE GLYPH FONT ID NAME SIZE ENCODING ==== ============== ===== ========= 0 Erg22.iso1.snf 12x30 ISO8859-1 1 Erg11.iso1.snf 8x15 ISO8859-1 I want to install more, how to obtain available fonts list ? What filesets I must install ?... (0 Replies)
Discussion started by: vilius
0 Replies

4. UNIX for Dummies Questions & Answers

Mounting an additional HW now no CLI

I have a SUN V245 with Solaris 10 newly installed. I have 4 73Gb HDs in this server and thought I'd use one of the other 3 to load some applications but after issueing a mount it appears that I no longer have a CLI interpreter -- # mount -F ufs /dev/dsk/c1t2d0s0 /usr # df bash:... (1 Reply)
Discussion started by: billwade
1 Replies

5. Linux

Additional mirrors on centos

How can I add additional mirrors to my CENTOS distro, according to this page AdditionalResources/Repositories - CentOS Wiki there are few fedora project repositories I'd like to add any of them but I don't know how? Thank you in advance (0 Replies)
Discussion started by: c0mrade
0 Replies

6. HP-UX

Difference between [condition] and [[condition]] and ((condition)) when used with if condition

Executed the following if conditions .. and got different results . only (( )) gave correct o/p with all scenarios . Can anybody please let me know what is the difference between and ] and ((condition)) when used with if condition. And why each condition gave different result. 1.... (2 Replies)
Discussion started by: soumyabubun
2 Replies

7. Shell Programming and Scripting

redirect stdout echo command in condition A run in condition B

hi, I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command Here are my simple script After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Discussion started by: jao_madn
3 Replies

8. UNIX for Dummies Questions & Answers

How to run additional shells

Hi, unix newbi here. Im currently on the bash shell, what are the commands to run additional shells? for example i want to run csh and then ksh? Thanks. BT. (2 Replies)
Discussion started by: BillThompson
2 Replies

9. Shell Programming and Scripting

If condition return 0 even when it fails to satisfy te condition

HI My doubt may be basic one but I need to get it clarified.. When i use "if" condition that checks for many AND, OR logical conditions like if ]; then return 0 fi Even the if condition fails it returns as zero.. Any clue.. But if i add else condition like if ]; ... (2 Replies)
Discussion started by: Priya Amaresh
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 06:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy