File concatenation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File concatenation
# 1  
Old 12-29-2014
File concatenation

Code:
 awk '{$2=$2":"$8"-"$3;$3=$NF;$4=$NF="";print $0 | $10=$10":"$8"-"$18;$11=$NF;$12=$NF="";print $0 }'  design.txt

Trying to concatenate specific fields in a spreadsheet and the others remain unchanged.

I attached an excel spreadsheet (all the data comes from a design.txt), but I put an example in there as well. Thank you Smilie.
# 2  
Old 12-29-2014
Insert a new column with a formula to concatenate the originals, them copy/paste values.
# 3  
Old 12-29-2014
Not sure what you are after, If you have just 1 excel sheet, why not use an excel formula and delete the columns you don't need,

Code:
 
 =CONCATENATE(I2,":",J2,"-",K2)


If you want to use awk, just blank out the columns you don't want,

Code:
 
 awk '{$2=$2":"$8"-"$3;$6=$6":"$7"-"$8;$3=$4=$7=$8="";}1'  file

# 4  
Old 12-30-2014
Not clear. Please be way more specific.

Do you want to work on a text file (with awk as in your sample code) or on a spread sheet (as indicated by post text and attachment)?

The awk script cannot run flawlessly. Do you want two lines (with different modifications) for every line in your input file? State in plain English what you want to have done.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Concatenation of multiple files based on file pattern

Hi, I have the following reports that get generated every 1 hour and this is my requirement: 1. 5 reports get generated every hour with the names "Report.Dddmmyy.Thhmiss.CTLR" "Report.Dddmmyy.Thhmiss.ACCD" "Report.Dddmmyy.Thhmiss.BCCD" "Report.Dddmmyy.Thhmiss.CCCD"... (1 Reply)
Discussion started by: Jesshelle David
1 Replies

2. Shell Programming and Scripting

Issue in Concatenation/Joining of lines in a dynamically generated file

Hi, I have a file containing many records delimited by pipe (|). Each record should contain 17 columnns/fields. there are some fields having fields less than 17.So i am extracting those records to a file using the below command awk 'BEGIN {FS="|"} NF !=17 {print}' feedfile.txt... (8 Replies)
Discussion started by: TomG
8 Replies

3. Shell Programming and Scripting

File Concatenation in a format

I have some files named as: error_abc.txt error_def.txt error_ghi.txt I want to concatenate all these into a single file say error_all.txt. The error_all.txt should be displayed like: ... (11 Replies)
Discussion started by: ankur328
11 Replies

4. Shell Programming and Scripting

Help with String concatenation

I have a script which is migrated from AIX to Linux & now while running it is no able to concatenate string values The string concatenation step under while loop is not displaying desired result Please find below the piece of code: while read EXT_FILE ; do EXT_FILE=$EXT_FILE.ext.sent echo... (7 Replies)
Discussion started by: PreetArul
7 Replies

5. Shell Programming and Scripting

Erroneous file concatenation.

I have more than one files in a directory , namely GLOW_OUT.txt FIELD_OUT.txt BASE_OUT.txt ... SHOW_OUT.txt What I wanted to do is to I am working in Korn Shell What I did was : for file in <directory_name>/*.* ;do cat $file | grep -v '^$' >> temp_file rm $file done ... (7 Replies)
Discussion started by: kumarjt
7 Replies

6. Shell Programming and Scripting

String concatenation

Hi, I have two files. cat file.txt a b c d cat file1.txt j k l m I need the output as a:j (12 Replies)
Discussion started by: nareshkumar522
12 Replies

7. Shell Programming and Scripting

Concatenation

How can I do this: date = 4 -----------> 04 Month= 3-----------> 03 I wish to make a varibale named Var1 which will hold the value of current date and month value as: 2 digits for date. 2 digits for month. So finally var1 should hold value as 0403 --- MMDD (11 Replies)
Discussion started by: Asteroid
11 Replies

8. UNIX for Dummies Questions & Answers

File Concatenation

Hi, I want to write a generic shell script, which can concatenate n number of files passed as parameter ;to an output file which is again a parameter Example catfl.sh outfl.txt a.txt b.txt c.txt (3 files to be concatenated into a file outfl.txt) catfl.sh outfl.txt a.txt b.txt(2 files to be... (3 Replies)
Discussion started by: samit_9999
3 Replies

9. Shell Programming and Scripting

File concatenation problem

I have written a script to find particular text files created within the last 24 hours and concatenate them all into a single concat.txt file. The problem that I am running into is that the last line of the text files do not terminate with <CR><LF> characters (as do all the other lines in each... (3 Replies)
Discussion started by: jvander
3 Replies

10. Shell Programming and Scripting

Concatenation

What is syntax for String concatenation? I have $1 as directory. $var is some variable value '/' String value. How do I have to concatenate if I have to run utility - util $1 followed by '/' followed by $var There is no space between these three. (2 Replies)
Discussion started by: videsh77
2 Replies
Login or Register to Ask a Question