Sponsored Content
Full Discussion: Concatenate text file
Top Forums Shell Programming and Scripting Concatenate text file Post 302922643 by Akshay Hegde on Monday 27th of October 2014 12:03:38 PM
Old 10-27-2014
Quote:
Originally Posted by cmccabe
Code:
 awk '{print $1 ":" $2 "-" $3 , OFS= /t$4}' file

Would the above concatenate $1,$2,$3 in column 1 and $4 in column 2? Thanks Smilie.
Your syntax is wrong, or else try like this

Code:
awk 'NF{$1=sprintf("%s:%s-%s",$1,$2,$3); $2=$4; NF-=2}1'  file

---------- Post updated at 10:33 PM ---------- Previous update was at 10:30 PM ----------

--
Quote:
Originally Posted by RavinderSingh13
Hello cmccabe,

Following will do the same what you have asked now, Akshay's solution is only printing the seprators in between fields.

Code:
awk '{$1=$1":"$2"-"$3;$2=$NF;$3=$NF="";print $0}'  Input_file

Thanks,
R. Singh
@Ravinder : $3=$NF="" will not delete fields actually, try your command with OFS=','
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

file Concatenate

Hi All, I have a question about file concatenate on unix. I have two file 1 of them like aaa,bbb,ccc,ddd other one is eee,fff,ggg,hhh I want to concatenate those file like this position aaa,bbb,ccc,ddd,eee,fff,ggg,hhh how can I do this ?? thanks. Alice (3 Replies)
Discussion started by: alisev
3 Replies

2. UNIX for Advanced & Expert Users

Concatenate text of two files in UNIX.

I have a file MyTest.csv saved in Unicode format in Incoming directory, and I have another file called MyTest.csv saved in ANSII format in InProcess Directory. I need to concatenate the text of both these files and put in another file MyTest.csv which is placed in the root directory. How do I... (1 Reply)
Discussion started by: Uniq
1 Replies

3. Shell Programming and Scripting

Insert file names when concatenate files into a file

Hi I found the following line would concatenate all test_01 test_02 test_03 files into "bigfile". cat test_* >> bigfile But, what I'm looking for a way to insert each file names in order when concatenated in "bigfile". Thank you samky2005 (2 Replies)
Discussion started by: samky2005
2 Replies

4. Shell Programming and Scripting

How to concatenate text files together

Hi. I'm attempting to copy 4 text files together to create one larger file. All four files contain text in the same format. Can I do this? I attempted this, but it didn't work: cp wscreening_test_h_po.dat+wscreening_test_b_po.dat+wscreening_test_h_notpo.dat... (1 Reply)
Discussion started by: buechler66
1 Replies

5. Shell Programming and Scripting

Concatenate strings retrieved from a file and write it into another file

Hi, I have a file files.txt containing data as below: abc;xyz uvw;pqr 123;456 I want to develop strings like below using the above data and write them into another file: www/xxx/abc/yyy/xyz www/xxx/uvw/yyy/pqr www/xxx/123/yyy/456 All this needs to be done through .sh file. ... (4 Replies)
Discussion started by: archana.n
4 Replies

6. Shell Programming and Scripting

Concatenate text between patterns in individual strings

In any given file, wherever a certain data block exists I need to concatenate the values(text after each "=" sign) from that block. in that block. The block starts and ends with specific pattern, say BEGIN DS and END DS respectively. The block size may vary. A file will have multiple such blocks.... (12 Replies)
Discussion started by: Prev
12 Replies

7. Programming

Concatenate string from text file

Hi mY files paths are defined as : //sbase = 'D:\data\sample_AMC\fasta_files\'; sbase2 = 'D:\data\sample_AMC\fasta_files\results\'; snameprefix = 'orig_ind'; snameprefix3 = 'results_ind'; ... const string filname = sbase + snameprefix + snamesuffix; const string resultsname_ =... (2 Replies)
Discussion started by: siya@
2 Replies

8. Shell Programming and Scripting

How to concatenate 2-columns by 2 -columns for a text file?

Hello, I want to concatenate 2-columns by 2-columns separated by colon. How can I do so? For example, I have a text file containing 6 columns separated by tab. I want to concatenate column 1 and 2; column 3 and 4; column 5 and 6, respectively, and put a colon in between. input file: 1 0 0 1... (10 Replies)
Discussion started by: huiyee1
10 Replies

9. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 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 07:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy