Sponsored Content
Top Forums Shell Programming and Scripting How to swap order of pairs of lines? Post 302488094 by pravin27 on Saturday 15th of January 2011 12:28:07 AM
Old 01-15-2011
Hi Try this,


Code:
awk '{if(NR%2){a=$0}else{print $0"\n"a;a=""}} END {if(a!=""){print a}}' inputfile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

reading lines in pairs from file in ksh

I need to read pairs of lines from a file and compare them. We can assume that the number of lines in the file is even. Can i do it in korn shell? (4 Replies)
Discussion started by: ytokar
4 Replies

2. Shell Programming and Scripting

How to grep lines in the particular order?

Hi guys, I am stuck on a simple issue but couldn't find a simple solution. If you have any ideas please help. I have two files : - FILE1 Tue 09/12 Lindsey Wed 09/13 Randy Thu 09/14 Susan Fri 09/15 Randy Sat 09/16 Lindsey Sun ... (2 Replies)
Discussion started by: sam_2921
2 Replies

3. Shell Programming and Scripting

Order file by lines

My script(3 arguments $1 = folder,$2 extension,$3 string) should do the following things: -Enter in the folder of $1(if exists). -Put ls *.$2 > temp.txt ( I use a temp file to store the result of ls command and if $2 = txt in this file I'll have all the .txt files of the folder) -Now I want to... (2 Replies)
Discussion started by: Max89
2 Replies

4. Shell Programming and Scripting

concatenate lines in pairs

Hi, I have a text file with the following contents /C=IT/O=INFN/OU=Personal Certificate/L=Napoli/CN=Some guy /C=IT/O=INFN/CN=INFN CA /O=Grid/O=NorduGrid/OU=uninett.no/CN=Another guy /O=Grid/O=NorduGrid/CN=NorduGrid Certification Authority /C=TW/O=AP/OU=GRID/CN=Someone else... (5 Replies)
Discussion started by: kerl
5 Replies

5. UNIX for Advanced & Expert Users

Swap lines using sed

Hi, I have to swap two consecutive line using sed in a file. My text to swap is available in the file x.pl #Create & map a common work library if (!(-e "../work")) { system ("vlib work ../work"); system ("vmap work ../work"); } system ("vsimsa -do thiagu_dec.do"); In this i... (6 Replies)
Discussion started by: adharmalingam
6 Replies

6. Shell Programming and Scripting

BASH: Swap first two lines in sets of 4

Hi. I may have mentioned in the OP to this thread that the AHK macro script I was trying to sort was, relative to its full length, only partly in the right format to be sorted by the methods discussed in that thread. Now I'm looking to tackle the rest of the data in that AHK script. ... (2 Replies)
Discussion started by: SilversleevesX
2 Replies

7. Shell Programming and Scripting

sed swap lines

Hi, I think it is possible with sed, but I'm not sure... I've a file that contains some text and filenames: gtk-media-pause | CB60471-05 - Gilbert, Brantley - Country Must Be Country Wide.zip | 8175 | /home/floris/Muziek/Karaoke/1341838939/CB60471-05 - Gilbert, Brantley - Country Must Be... (2 Replies)
Discussion started by: jkfloris
2 Replies

8. UNIX for Advanced & Expert Users

Parse (delimited string) key-value pairs in a column into separate lines

Hi experts, e.g. i/p data looks like 0000xm7zcNDIkP888vRqGv93xA7:176n00qql||9700005405552747,9700005405717924,9700005405733788|unidentified,unidentified,unidentified|| o/p data should like - row1: 0000xm7zcNDIkP888vRqGv93xA7:176n00qql||9700005405552747|unidentified ... (1 Reply)
Discussion started by: sumoka
1 Replies

9. Shell Programming and Scripting

File w/ many line pairs--how do I order based on 1st lines only?

I have a file in which the data is stored in pairs of lines. The first line (beginining with ">") is a header, the second line is a sequence. I would like to sort the file by species name. Desired output for the example file: I can use sort -t'_' -k2 to alphabetize headers in the... (1 Reply)
Discussion started by: pathunkathunk
1 Replies

10. Shell Programming and Scripting

Remove lines with duplicate pairs where AB is equal to BA

I have a file with four columns like dmn10003t1 PF00001 PF00022 dmn12390t1 dmn10008t1 PF00069 PF00027 dmn9781t1 dmn10008t1 PF00068 PF00027 dmn9781t1 dmn10008t1 PF00069 PF00069 dmn9781t1 dmn12390t1 PF00069 PF00076 dmn10003t1 I want to create a new file by comparing the repeated word pairs... (2 Replies)
Discussion started by: sammy777
2 Replies
DEBCONF-SET-SELECTIONS(1)					      Debconf						 DEBCONF-SET-SELECTIONS(1)

NAME
debconf-set-selections - insert new default values into the debconf database SYNOPSIS
debconf-set-selections file debconf-get-selections | ssh newhost debconf-set-selections DESCRIPTION
debconf-set-selections can be used to pre-seed the debconf database with answers, or to change answers in the database. Each question will be marked as seen to prevent debconf from asking the question interactively. Reads from a file if a filename is given, otherwise from stdin. WARNING
Only use this command to seed debconf values for packages that will be or are installed. Otherwise you can end up with values in the database for uninstalled packages that will not go away, or with worse problems involving shared values. It is recommended that this only be used to seed the database if the originating machine has an identical install. DATA FORMAT
The data is a series of lines. Lines beginning with a # character are comments. Blank lines are ignored. All other lines set the value of one question, and should contain four values, each separated by one character of whitespace. The first value is the name of the package that owns the question. The second is the name of the question, the third value is the type of this question, and the fourth value (through the end of the line) is the value to use for the answer of the question. Alternatively, the third value can be "seen"; then the preseed line only controls whether the question is marked as seen in debconf's database. Note that preseeding a question's value defaults to marking that question as seen, so to override the default value without marking a question seen, you need two lines. Lines can be continued to the next line by ending them with a "" character. EXAMPLES
# Force debconf priority to critical. debconf debconf/priority select critical # Override default frontend to readline, but allow user to select. debconf debconf/frontend select readline debconf debconf/frontend seen false OPTIONS
--verbose, -v verbose output --checkonly, -c only check the input file format, do not save changes to database SEE ALSO
debconf-get-selections(1) (available in the debconf-utils package) AUTHOR
Petter Reinholdtsen <pere@hungry.com> 2012-09-10 DEBCONF-SET-SELECTIONS(1)
All times are GMT -4. The time now is 08:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy