Sponsored Content
Full Discussion: Combine lines from file
Top Forums UNIX for Dummies Questions & Answers Combine lines from file Post 302685271 by shitson on Saturday 11th of August 2012 11:29:45 PM
Old 08-12-2012
This is a very basic start, i'm sure something much more elegant could be done with awk Smilie

Code:
#!/bin/bash

FILE="/tmp/file.txt"
COUNT=1

for i in `cat ${FILE}`
do
	if [ "$((${COUNT}%2))" -eq 1 ]
	then	
		echo -n "${i}"
	else
		echo " ${i}"
	fi	

	let COUNT=$COUNT+1
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I combine the last 2 lines of a file

I tried to put the history line number and the date into the file with one command, and failed. Can't figure out how to get the date variable substituted for the last space captured. history | tail -1 | sed -e 's/.\{7\}/&/g' | head -1 | sed 's/ $/$date/' Result was: 729 $date So, I... (8 Replies)
Discussion started by: jimbob75
8 Replies

2. Shell Programming and Scripting

Combine all lines of a file with all lines of another file.

Dear all, I would like to combine all lines of a file with all lines of another file: The input are file 1 A B C D file 2 A B C D The output is final file A_A A_B A_C (3 Replies)
Discussion started by: valente
3 Replies

3. Shell Programming and Scripting

Combine multiple lines in file based on specific field

Hi, I have an issue to combine multiple lines of a file. I have records as below. Fields are delimited by TAB. Each lines are ending with a new line char (\n) Input -------- ABC 123456 abcde 987 890456 7890 xyz ght gtuv ABC 5tyin 1234 789 ghty kuio ABC ghty jind 1234 678 ght ... (8 Replies)
Discussion started by: ratheesh2011
8 Replies

4. Shell Programming and Scripting

Combine multiple unique lines from event log text file into one line, use PERL or AWK?

I can't decide if I should use AWK or PERL after pouring over these forums for hours today I decided I'd post something and see if I couldn't get some advice. I've got a text file full of hundreds of events in this format: Record Number : 1 Records in Seq : ... (3 Replies)
Discussion started by: Mayday22
3 Replies

5. UNIX for Dummies Questions & Answers

Combine lines in file

Hi All, I am trying to understand if its possible to carry out the following. I have a text file which contains output from multiple commands, within the file a node will be quiered twice if there was 2 commands for example. Is it possible do combine 2 lines into 1 if the first word is the... (1 Reply)
Discussion started by: mutley2202
1 Replies

6. UNIX for Dummies Questions & Answers

Need to combine two lines in a file based on first character of each line in a file

Hi, I have a requirement where I need to combine two lines in a file based on first character of each line in a file. Please find the sample content of the file below: Code: _______________________ 5, jaya, male, 4-5-90, single smart 6, prakash, male, 5-4-84, married fair 7, raghavi,... (1 Reply)
Discussion started by: jayaP
1 Replies

7. UNIX for Advanced & Expert Users

Need to combine two lines in a file based on first character of each line in a file

Hi, I have a requirement where I need to combine two lines in a file based on first character of each line in a file. Please find the sample content of the file below: Code: _______________________ 5, jaya, male, 4-5-90, single smart 6, prakash, male, 5-4-84, married fair 7, raghavi,... (1 Reply)
Discussion started by: jayaP
1 Replies

8. Shell Programming and Scripting

Program to combine two lines in a file on checking the first character of each line

Hi, I have a requirement where I need to combine two lines in a file based on first character of each line in a file. Please find the sample content of the file below: _______________________ 5, jaya, male, 4-5-90, single smart 6, prakash, male, 5-4-84, married fair 7, raghavi, female,... (12 Replies)
Discussion started by: jayaP
12 Replies

9. Shell Programming and Scripting

awk to combine matching lines in file

I am trying to combine all matching lines in the tab-delimited using awk. The below runs but no output results. Thank you :). input chrX 110925349 110925532 ALG13 chrX 110925349 110925532 ALG13 chrX 110925349 110925532 ALG13 chrX 47433390 47433999 SYN1... (3 Replies)
Discussion started by: cmccabe
3 Replies

10. Shell Programming and Scripting

Script to combine lines in a file

Greetings, I have large file with following format name1 name2 name3 name4 name5 name6 child7 child8 child9 <== there is leading blank space child10 child11 child12 <== there is leading blank space name13 name14 name15 name16 child17 child18... (6 Replies)
Discussion started by: rnnyusa
6 Replies
dwz(1)							      General Commands Manual							    dwz(1)

NAME
dwz - DWARF optimization and duplicate removal tool SYNOPSIS
dwz [OPTION...] [FILES] DESCRIPTION
dwz is a program that attempts to optimize DWARF debugging information contained in ELF shared libraries and ELF executables for size, by replacing DWARF information representation with equivalent smaller representation where possible and by reducing the amount of duplication using techniques from DWARF standard appendix E - creating DW_TAG_partial_unit compilation units (CUs) for duplicated information and using DW_TAG_imported_unit to import it into each CU that needs it. The tool handles DWARF 32-bit format debugging sections of versions 2, 3 and 4 and GNU extensions on top of those, though using DWARF 4 or worst case DWARF 3 is strongly recommended. The tool has two main modes of operation, without the -m option it attempts to optimize DWARF debugging information in each given object (executable or shared library) individually, with the -m option it afterwards attempts to optimize even more by moving DWARF debugging information entries (DIEs), strings and macro descriptions duplicated in more than one object into a newly created ELF ET_REL object whose filename is given as -m option argument. The debug sections in the executables and shared libraries specified on the command line are then modified again, referring to the entities in the newly created object. OPTIONS
-m FILE --multifile FILE Multifile mode. After processing all named executables and shared libraries, attempt to create ELF object FILE and put debugging information duplicated in more than one object there, afterwards optimize each named executable or shared library even further if possible. -h --hardlink Look for executables or shared libraries hardlinked together, instead of rewriting them individually rewrite just one of them and hardlink the rest to the first one again. -M NAME --multifile-name NAME Specify the name of the common file that should be put into the .gnu_debugaltlink section alongside with its build ID. By default dwz puts there the argument of the -m option. -r --relative Specify that the name of the common file to be put into the .gnu_debugaltlink section is supposed to be relative path from the directory containing the executable or shared library to the file named in the argument of the -m option. Either -M or -r option can be specified, but not both. -q --quiet Silence up some of the most common messages. -o FILE --output FILE This option instructs dwz not to overwrite the specified file, but instead store the new content into FILE. Nothing is written if dwz exits with non-zero exit code. Can be used only with a single executable or shared library (if there are no arguments at all, a.out is assumed). -l COUNT --low-mem-die-limit COUNT Handle executables or shared libraries containing more than COUNT debugging information entries in their .debug_info section using a slower and more memory usage friendly mode and don't attempt to optimize that object in multifile mode. The default is 10 million DIEs. There is a risk that for very large amounts of debugging information in a single shared library or executable there might not be enough memory (especially when dwz tool is 32-bit binary, it might run out of available virtual address space even sooner). -L COUNT --max-die-limit COUNT Don't attempt to optimize executables or shared libraries containing more than COUNT DIEs at all. The default is 50 million DIEs. -? --help Print short help and exit. ARGUMENTS
Command-line arguments should be the executables, shared libraries or their stripped to file separate debug information objects. EXAMPLES
$ dwz -m .dwz/foobar-1.2.debug -rh bin/foo.debug bin/foo2.debug foo/lib/libbar.so.debug will attempt to optimize debugging information in bin/foo.debug, bin/foo2.debug and lib/libbar.so.debug (by modifying the files in place) and when beneficial also will create .dwz/foobar-1.2.debug file. .gnu_debugaltlink section in the first two files will refer to ../.dwz/foobar-1.2.debug and in the last file to ../../.dwz/foobar-1.2.debug. If e.g. bin/foo.debug and bin/foo2.debug were hardlinked together initially, they will be hardlinked again and for multifile optimizations considered just as a single file rather than two. $ dwz -o foo.dwz foo will not modify foo but instead store the ELF object with optimized debugging information if successful into foo.dwz file it creates. $ dwz *.debug foo/*.debug will attempt to optimize debugging information in *.debug and foo/*.debug files, optimizing each file individually in place. $ dwz is equivalent to dwz a.out command. SEE ALSO
http://dwarfstd.org/doc/DWARF4.pdf , gdb(1). AUTHORS
Jakub Jelinek <jakub@redhat.com>. 15 June 2012 dwz(1)
All times are GMT -4. The time now is 08:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy