Sponsored Content
Top Forums UNIX for Dummies Questions & Answers merging 2 lines with awk and stripping first two words Post 302249869 by zaxxon on Wednesday 22nd of October 2008 08:58:03 AM
Old 10-22-2008
If you use [ code ] tags, it won't, as you did already Smilie
Code:
^save set

The ^ is the problem. If you replace it with a blank and an asterix " *", it will work, but then it's getting ugly since the leading spaces are not removed.

Is a solution in sed ok too? I can write it more compact than in awk. Else you might have to wait for other people to post. I also had an error in it - i edited my 1st post.
I added the sed thing at the end to remove the lots of blanks out of the line, occuring by the changed input file.
Output should be ok, but not very compact.

Last edited by zaxxon; 10-22-2008 at 10:05 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merging files with AWK filtering and counting lines

Hi there, I have a couple of files I need to merge. I can do a simple merge by concatenating them into one larger file. But then I need to filter the file to get a desired result. The output looks like this: TRNH 0000000010941 ORDH OADR OADR ORDL ENDT 1116399 000000003... (2 Replies)
Discussion started by: Meert
2 Replies

2. Shell Programming and Scripting

Merging lines using AWK

Hi, Anybody help on this. :( I want to merge the line with previous line, if the line starts with 7. Otherwise No change in the line. Example file aa.txt is like below 122122 222222 333333 734834 702923 389898 790909 712345 999999 My output should be written in another file... (6 Replies)
Discussion started by: senthil_is
6 Replies

3. UNIX for Dummies Questions & Answers

[bash]Stripping lines from a list

Hello! I have a script that is (among other things) doing the following: list=/tmp/list1.txt ncftpls -u <user> -p <password> -x "-l1" server.domain.tld > $list cat $list | nl echo "Choose file: " read file cat /tmp/list1.txt | nl | grep $file | sed -e "s/$file//g" -e "s/ //g" | column -t... (8 Replies)
Discussion started by: noratx
8 Replies

4. Shell Programming and Scripting

Urgent help needed on merging lines with similar words

Hi everyone, I need help with a merging problem. Basically, I have a file with several lines (in this example 9 lines) such as: Amie, Jay, Sasha, Rob, Kay Mia, Frank Jay, Nancy, Cecil Paul, Ked, Nancy, 17, Fred 14, 16, 18, 20 9, 11 12, Frank 18, Peter, 62 Nancy, 27 A delimiter is... (3 Replies)
Discussion started by: awb221
3 Replies

5. Shell Programming and Scripting

awk help needed in trying to count lines,words and characters

Hello, i am trying to write a script file in awk which yields me the number of lines,characters and words, i checked it many many times but i am not able to find any mistake in it. Please tell me where i went wrong. BEGIN{ print "Filename Lines Words Chars\n" } { filename=filename + 1... (2 Replies)
Discussion started by: salman4u
2 Replies

6. Shell Programming and Scripting

Swapping lines beginning with certain words using sed/awk

I have a large file which reads like this: fixed-address 192.168.6.6 { hardware ethernet 00:22:64:5b:db:b1; host X; } fixed-address 192.168.6.7 { hardware ethernet 00:22:64:5b:db:b3; host Y; } fixed-address 192.168.6.8 { hardware ethernet 00:22:64:5b:db:b4; host A; }... (4 Replies)
Discussion started by: ksk
4 Replies

7. Shell Programming and Scripting

Merging words splitted into characters with awk

I have an OCR output with some words splitted into single characters separated by blank spaces, and I want the same text with these words written correctly. Example: This is a text w i t h some s p l i t e d W o r d s . The regular expression for matching splitted words could be something... (5 Replies)
Discussion started by: dokamo
5 Replies

8. Shell Programming and Scripting

Count words/lines between two tags using awk

Is there an efficient awk that can count the number of lines that occur in between two tags. For instance, consider the following text: <s> Hi PP - my VBD - name DT - is NN - . SENT . </s> <s> Her PP - name VBD - is DT - the NN - same WRT - . SENT - </s> I am interested to know... (4 Replies)
Discussion started by: owwow14
4 Replies

9. Shell Programming and Scripting

Merging multiple lines to columns with awk, while inserting commas for missing lines

Hello all, I have a large csv file where there are four types of rows I need to merge into one row per person, where there is a column for each possible code / type of row, even if that code/row isn't there for that person. In the csv, a person may be listed from one to four times... (9 Replies)
Discussion started by: RalphNY
9 Replies

10. UNIX for Beginners Questions & Answers

Merging two lines into one (awk)

Hi, I am attempting to merge the following lines which run over two lines using awk. INITIAL OUTPUT 2019 Sep 28 10:47:24.695 hkaet9612 last message repeated 1 time 2019 Sep 28 10:47:24.695 hkaet9612 %ETHPORT-5-IF_DOWN_INTERFACE_REMOVED: Interfa ce Ethernet1/45 is down (Interface removed)... (10 Replies)
Discussion started by: sand1234
10 Replies
compact(1)						      General Commands Manual							compact(1)

NAME
compact, uncompact, ccat - compact and uncompact files, and cat them SYNOPSIS
[sfile] ... [cfile] ... [cfile] ... DESCRIPTION
compresses the named files using an adaptive Huffman code. If no file names are given, standard input is compacted and sent to the stan- dard output. operates as an on-line algorithm. Each time a byte is read, it is encoded immediately according to the current prefix code. This code is an optimal Huffman code for the set of frequencies seen so far. It is unnecessary to attach a decoding tree in front of the compressed file because the encoder and the decoder start in the same state and stay synchronized. Furthermore, and can operate as fil- ters. In particular, operates as a (very slow) no-op. When an argument file is given, it is compacted, the resulting file is placed in and file is unlinked. The first two bytes of the com- pacted file code the fact that the file is compacted. These bytes are used to prohibit recompaction. The amount of compression to be expected depends on the type of file being compressed. Typical file size reduction (in percent) through compression are: Text, 38%; Pascal Source, 43%; C Source, 36%; and Binary, 19%. restores the original file from a file compressed by If no file names are specified, standard input is uncompacted and sent to the standard output. writes the specified c_file, compressed by to standard output, without uncompressing the file. Operands The commands recognize the following operands: cfile Compacted file. sfile Source file to compact or uncompact. If no file names are given, the commands use standard input and sent to the standard output. places the compacted file in Access Control Lists (ACLs) On systems that implement access control lists, when a new file is created with the effective user and group ID of the caller, the original file's ACL is copied to the new file after being altered to reflect any change in ownership (see acl(5) and aclv(5)). In JFS file systems, files created by or do not inherit their parent directory's default ACL entries (if any), but instead retain their original ACLs. When a file being compacted or uncompacted resides on a JFS file system, and the compacted or uncompacted file resides on an HFS file system (or vice versa), as the result of or the use of or as a filter, optional ACL entries are lost. WARNINGS
On short-file-name systems, the last segment of the file name must contain 12 or fewer characters to allow space for the appended DEPENDENCIES
NFS Access control list entries of networked files are summarized (as returned in by but not copied to the new file (see stat(2)). AUTHOR
was developed by Colin L. Mc Master. FILES
compacted file created by compact, removed by uncompact SEE ALSO
compress(1), pack(1), acl(5), aclv(5). Gallager, Robert G., "Variations on a Theme of Huffman," vol. IT-24, no. 6, November 1978, pp. 668 - 674. compact(1)
All times are GMT -4. The time now is 08:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy