Sponsored Content
Full Discussion: Help Moving lines
Top Forums Shell Programming and Scripting Help Moving lines Post 302585027 by r4v3n on Tuesday 27th of December 2011 05:41:30 AM
Old 12-27-2011
Help Moving lines

Hi,

I tried going through the existing threads, but couldn't find a solution to my problem. My input file is:

Code:
199.15.2.7|gxi.wxxx.com/|(Mozilla/4.0)|
ASCII text|950604ad05
70.38.9.7|mmg10.com/2011/1.gif|(Mozilla/4.0)|
application/x-ms-dos-executable|a2f332Y02d0
70.38.9.2|vim105.com/113856471.gif|(Mozilla/4.0)|
application/x-ms-dos-executable|aed7d0cK80a0

My output file should look like:
Code:
199.15.2.7|gxi.wxxx.com/|(Mozilla/4.0)|ASCII text|950604ad05
70.38.9.7|mmg10.com/2011/1.gif|(Mozilla/4.0)|application/x-ms-dos-executable|a2f332Y02d0
70.38.9.2|vim105.com/113856471.gif|(Mozilla/4.0)|application/x-ms-dos-executable|aed7d0cK80a0

How do I do this in sed or awk? It should look for the | symbol at end of line, and if it is present, bring the line below that up.

Any help with explanation would be appreciated
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

moving between vi files

would any one please tell me which keys we used between opened vi files backward and forward Thanks Ayah (2 Replies)
Discussion started by: aya_r
2 Replies

2. UNIX for Advanced & Expert Users

help in moving

can any one help i have a file with this content file name hsnvalue.op containing HSN=0,tool=123 HSN=0,tool=123 HSN=0,tool=123 HSN=0,tool=123 HSN=0,tool=123 HSN=0,tool=123 i want to print only one value to another file final.out :confused: (5 Replies)
Discussion started by: shafique
5 Replies

3. Shell Programming and Scripting

Moving next 2 lines contents to previous lines

My input file is aaa bbb ccc a1a b1b c1c a2a b2b c2c I want the output file to look like that: aaa,bbb,ccc a1a,b1b,c1c a2a,b2b,c2c How do I achieve this ? (8 Replies)
Discussion started by: Amruta Pitkar
8 Replies

4. UNIX for Dummies Questions & Answers

How to count lines - ignoring blank lines and commented lines

What is the command to count lines in a files, but ignore blank lines and commented lines? I have a file with 4 sections in it, and I want each section to be counted, not including the blank lines and comments... and then totalled at the end. Here is an example of what I would like my... (6 Replies)
Discussion started by: kthatch
6 Replies

5. Shell Programming and Scripting

Moving lines within a txt file

A newbie to shell scripting..... I need some assistance in doing the following: I have a system generated text file(a makefile basically). Before I can execute the make command, I need to modify one section of this generated file. The generated section is as follows: # INCLUDE macro... (5 Replies)
Discussion started by: innocentspirit
5 Replies

6. Shell Programming and Scripting

deleting particular lines and moving a line up using perl/sed

Hi, I need convert a dump file in the following format : (please note that line numbers are provided for easy look) Original file: 1 2007-10-2482.90 No trade 0 0.00 100000.00 2 100000.00 3 0.00 4 HOLD 5 2007-10-2589.75 Bought 1114 1114 100000.00 0.00 ... (5 Replies)
Discussion started by: sabyasm
5 Replies

7. Shell Programming and Scripting

not moving !!

Hi I have written the following piece of code to move all files with name *.sh to *.bak the o/p i am getting is *.sh.bak Pls help cat filename | while read line do mv $line $line.sh done filename file conatins file.sh file1.sh file2.sh expected o/p is file.bak (2 Replies)
Discussion started by: ultimatix
2 Replies

8. UNIX for Dummies Questions & Answers

Moving lines of file to command line

I have a file in which each line is the name of another file. Is there a way to serve them to the command line? For example, if the file contains file1.txt file2.txt file3.txt ... file9.txt is there a way to insert them in the command as a batch? If I ran a command like grep... (4 Replies)
Discussion started by: wbport
4 Replies

9. Shell Programming and Scripting

awk two succeeding lines and moving matching files

Hello everyone I have a few hundreds of .mol2 files that has this pattern @<TRIPOS>ATOM 2 H18 65.2220 Du 1 RES1 0.0000 @<TRIPOS>BOND 1 3 5 ar @<TRIPOS>SUBSTRUCTURE among them, some of the files are missing the line after the @<TRIPOS>BOND and they look... (2 Replies)
Discussion started by: Error404
2 Replies

10. Shell Programming and Scripting

Sed: how to merge two lines moving matched pattern to end of previous line

hello everyone, im new here, and also programming with awk, sed and grep commands on linux. In my text i have many lines with this config: 1 1 4 3 1 1 2 5 2 2 1 1 1 3 1 2 1 3 1 1 1 2 2 2 5 2 4 1 3 2 1 1 4 1 2 1 1 1 3 2 1 1 5 4 1 3 1 1... (3 Replies)
Discussion started by: satir
3 Replies
cr(1)							      General Commands Manual							     cr(1)

NAME
cr - converts text files between nix EOL and dos EOL SYNOPSIS
cr - | + <input file> <output file> DESCRIPTION
Text files, such as tle files, that come from a dos source usualy have the ^M symbol at the end of every line. Cr converts files between the dos newline format and the normal *nix newline format by stripping the ^M to convert dos to *nix, using the '-' option, or adding ^M to a *nix file to create the proper dos file when the '+' option is used. Although this extra character is not often a problem, programs like seesat5, which are data driven will encounter parsing problems when the extra character is present. It is these problems that cr is intended to repair. Options - | + One or the other of these options is required. The '-' option is used to remove ^M from all newlines found in the dos file. The '+' option is used to add ^M to every newline found in a *nix file. input file Fully delineated path to the input file. As this program is used in the dos environment as well, standard input is not used. output file Fully delineated path to the output file. As this program is used in the dos environment as well, standart output is not used. SEE ALSO
seesat5(1), seesat5(7), SEESAT5.INI(5), tle(5) BUGS
Cr is not an inteligent program. It methodicaly replaces/removes the offending character when it finds it in the correct context. Newline sequences found in contexts other than 'newline' will be replaced/removed just like those found in the proper context. Passing a binary file through cr is not advised, for this reason. Send all inqueries to Dale Scheetz <dwarf@polaris.net>. Debian Linux 2 April 96 cr(1)
All times are GMT -4. The time now is 10:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy