Sponsored Content
Top Forums Shell Programming and Scripting Manipulation row order in file Post 303023550 by baris35 on Wednesday 19th of September 2018 07:13:05 AM
Old 09-19-2018
Manipulation row order in file

Hello,
I am trying to replace the position of each row by the next row.
OS: Ubuntu 18.04, bionic
I'd appreciate your help.

input_file:
Code:
-O fileA
wget http://x.y.z./a
-O fileB
wget http://a.b.c./d
-O fileC
wget http://q.f.s/t
..
..
..
-O fileZZ
wget http://r.t.y/u

I expect:
Code:
wget http://x.y.z./a
-O fileA
wget http://a.b.c./d
-O fileB
wget http://q.f.s/t
-O fileC
..
..
..
wget http://r.t.y/u
-O fileZZ

or

Code:
wget http://x.y.z./a -O fileA
wget http://a.b.c./d -O fileB
wget http://q.f.s/t -O fileC
..
..
..
wget http://r.t.y/u -O FileZZ

I tried different combinations of below command but not as expected.

Code:
sed -n '{p;n;};h;p;n;p' input_file

many thanks
Boris

------ Post updated at 06:13 AM ------

Weird method but okay for me:

Code:
awk 'NR % 2 == 1' input_file > odd_lines
awk 'NR % 2 == 0' input_file > even_lines
paste -d'\n' even_lines odd_lines > expected_output

many thanks
Boris

Last edited by baris35; 09-19-2018 at 11:42 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Changing the column for a row in a text file and adding another row

Hi, I want to write a shell script which increments a particular column in a row from a text file and then adds another row below the current row with the incremented value . For Eg . if the input file has a row : abc xyz lmn 89 lm nk o p I would like the script to create something like... (9 Replies)
Discussion started by: aYankeeFan
9 Replies

2. Shell Programming and Scripting

Append Second Row to First Row @ end in a file

Hi I want to append line 2n to 2n-1 line where n=1...LastLine in my file. eg: Actual File: Hello Everyone Welcome TO Unix I need Your help Required File: HelloEveryone WelcomeTO Unix I needYour help (5 Replies)
Discussion started by: dashing201
5 Replies

3. Shell Programming and Scripting

Get a group of line from different file and put them into one file row by row

hi guys, today i'm stuck in a new problem. the title explain more or less but a particular had been omitted. So i'm going to describe below the situation with an example. I have different html files and each of them have a consecutive lines group inside that i want to extract. example: ... (8 Replies)
Discussion started by: sbobotex
8 Replies

4. Shell Programming and Scripting

String manipulation row by row

Dear masters, I stuck again in a very tricky situation,so need your valuable inputs. I have a file having rows as below: _Db _Database 1023 1 1 1 17.0B 0.2 1.0 _Field _Field-Name 3 2 2 11 56.2K 64.1 ... (5 Replies)
Discussion started by: patric2326
5 Replies

5. UNIX for Dummies Questions & Answers

Column to row - in order to create zones

i need a script that reads a wwn file like this: LOCAL_HOST (before) 50:01:24:82:00:6c:a9:04 21:00:00:24:ff:30:35:7b 21:00:00:24:ff:30:35:70and will run over the file with all the wwn's in the same row in order to create zones on a switch like so: LOCAL_HOST (after) zonecreate " (... (2 Replies)
Discussion started by: boaz733
2 Replies

6. Shell Programming and Scripting

Subtracting each row from the first row in a single column file using awk

Hi Friends, I have a single column data like below. 1 2 3 4 5 I need the output like below. 0 1 2 3 4 where each row (including first row) subtracting from first row and the result should print below like the way shown in output file. Thanks Sid (11 Replies)
Discussion started by: ks_reddy
11 Replies

7. Shell Programming and Scripting

Read row number from 1 file and print that row of second file

Hi. How can I read row number from one file and print that corresponding record present at that row in another file. eg file1 1 3 5 7 9 file2 11111 22222 33333 44444 55555 66666 77777 88888 99999 (3 Replies)
Discussion started by: Abhiraj Singh
3 Replies

8. Shell Programming and Scripting

Search row by row from one file to another file if match is found print few colums of file 2

this is the requirement list.txt table1 table2 table3 testfile.txt name#place#data#select * from table1 name2#place2#data2#select * from table 10 innerjoin table3 name2#place2#data2#select * from table 10 output name place table1 name2 place table3 i tried using awk (7 Replies)
Discussion started by: vamsekumar
7 Replies

9. Shell Programming and Scripting

File in ascending order by row

Hi All I have a file like this: ID1 ref_A 10 ref_B 30 ref_C 5 ID2 ref_F 69 ref_G 12 ref_H 5 Every ID is followed by a string(ref_X) followed by a number(every number is referred to the previous ref) I would like to order the file like this(the column could be more, but always with the same... (4 Replies)
Discussion started by: giuliangiuseppe
4 Replies

10. Shell Programming and Scripting

How to change row by order nr?

Hello, I have a file with thousands of rows and I need to change sequence of lines. Sample file: #NAME #SERVICE 112233 #DESCRIPTION AABBCCDD #SERVICE 738292 #DESCRIPTION FFYYRRTT ... ... ... Desired output: #NAME (5 Replies)
Discussion started by: baris35
5 Replies
Gedcom::WebServices(3pm)				User Contributed Perl Documentation				  Gedcom::WebServices(3pm)

NAME
Gedcom::WebServices - Basic web service routines for Gedcom.pm Version 1.16 - 24th April 2009 SYNOPSIS
wget -qO - http://www.example.com/ws/plain/my_family/i9/name DESCRIPTION
This module provides web service access to a GEDCOM file in conjunction with mod_perl. Using it, A request for imformation can be made in the form of a URL specifying the GEDCOM file to be used, which information is required and the format in which the information is to be delivered. This information is then returned in the specified format. There are currently three supported formats: o plain - no markup o XML o JSON URLs The format of the URLs used to access the web services are: $BASEURL/$FORMAT/$GEDCOM/$XREF/requested/information $BASEURL/$FORMAT/$GEDCOM?search=search_criteria BASEURL The base URL to access the web services. FORMAT The format in which to return the results. GEDCOM The name of the GEDCOM file to use (the extension .ged is assumed). XREF The xref of the record about which information is required. XREFs can be obtained initially from a search, and subsequently from certain queries. requested/information The information requested. This is in the same format as that taken by the get_value method. search_criteria An individual to search for. This is in the same format as that taken by the get_individual method. EXAMPLES
$ wget -qO - 'http://pjcj.sytes.net:8585/ws/plain/royal92?search=elizabeth_ii' /ws/plain/royal92/I52 $ wget -qO - http://pjcj.sytes.net:8585/ws/plain/royal92/I52 0 @I52@ INDI 1 NAME Elizabeth_II Alexandra Mary/Windsor/ 1 TITL Queen of England 1 SEX F 1 BIRT 2 DATE 21 APR 1926 2 PLAC 17 Bruton St.,London,W1,England 1 FAMS @F14@ 1 FAMC @F12@ $ wget -qO - http://pjcj.sytes.net:8585/ws/plain/royal92/I52/name Elizabeth_II Alexandra Mary /Windsor/ $ wget -qO - http://pjcj.sytes.net:8585/ws/plain/royal92/I52/birth/date 21 APR 1926 $ wget -qO - http://pjcj.sytes.net:8585/ws/plain/royal92/I52/children /ws/plain/royal92/I58 /ws/plain/royal92/I59 /ws/plain/royal92/I60 /ws/plain/royal92/I61 $ wget -qO - http://pjcj.sytes.net:8585/ws/json/royal92/I52/name {"name":"Elizabeth_II Alexandra Mary /Windsor/"} $ wget -qO - http://pjcj.sytes.net:8585/ws/xml/royal92/I52/name <NAME>Elizabeth_II Alexandra Mary /Windsor/</NAME> $ wget -qO - http://pjcj.sytes.net:8585/ws/xml/royal92/I52 <INDI ID="I52"> <NAME>Elizabeth_II Alexandra Mary/Windsor/</NAME> <TITL>Queen of England</TITL> <SEX>F</SEX> <BIRT> <DATE>21 APR 1926</DATE> <PLAC>17 Bruton St.,London,W1,England</PLAC> </BIRT> <FAMS REF="F14"/> <FAMC REF="F12"/> </INDI> CONFIGURATION
Add a section similar to the following to your mod_perl config: PerlWarn On PerlTaintCheck On PerlPassEnv GEDCOM_TEST <IfDefine GEDCOM_TEST> <Perl> $Gedcom::TEST = 1; </Perl> </IfDefine> <Perl> use Apache::Status; $ENV{PATH} = "/bin:/usr/bin"; delete @ENV{"IFS", "CDPATH", "ENV", "BASH_ENV"}; $Gedcom::DATA = $Gedcom::ROOT; # location of data stored on server use lib "$Gedcom::ROOT/blib/lib"; use Gedcom::WebServices; my $handlers = [ qw ( plain xml json ) ]; eval Gedcom::WebServices::_set_handlers($handlers); # use Apache::PerlSections; print STDERR Apache::PerlSections->dump; </Perl> PerlTransHandler Gedcom::WebServices::_parse_uri BUGS
Very probably. See the BUGS file. And the TODO file. VERSION
Version 1.16 - 24th April 2009 LICENCE
Copyright 2005-2009, Paul Johnson (paul@pjcj.net) This software is free. It is licensed under the same terms as Perl itself. The latest version of this software should be available from my homepage: http://www.pjcj.net perl v5.14.2 2012-04-12 Gedcom::WebServices(3pm)
All times are GMT -4. The time now is 03:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy