Sponsored Content
Full Discussion: Shift Characters in Text
Top Forums UNIX for Dummies Questions & Answers Shift Characters in Text Post 302321637 by TonyFullerMalv on Monday 1st of June 2009 06:52:35 PM
Old 06-01-2009
Not entirely sure what you are after as both columns contain the same data but if want to swap what is in the first column with what is in the second column you could do:
Code:
$ awk '{ print $2" "$1 }' inputfile > outputfile

e.g.:
Code:
$ cat inputfile
aaa bbb
ccc ddd
1000 2000
1001 2002
$ awk '{ print $2" "$1 }' inputfile > outputfile
$ cat outputfile
bbb aaa
ddd ccc
2000 1000
2002 1001
$

If you want to replace what is in the first column with what is in the second column then you could do:
Code:
$ awk '{ print $2" "$2 }' inputfile > outputfile

e.g.
Code:
~$ awk '{ print $2" "$2 }' inputfile > outputfile
$ cat outputfile
bbb bbb
ddd ddd
2000 2000
2002 2002
$


Last edited by TonyFullerMalv; 06-01-2009 at 07:54 PM.. Reason: Second option
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Display text between two words/characters

Using sed or awk, I need to display text between two words/characters. Below are two example inputs and the desired output. In a nutshell, I need the date-range value between the quotes (but only the first occurance of date-range as there can be more than one). Example One Input: xml-report... (1 Reply)
Discussion started by: cmichaelson
1 Replies

2. Shell Programming and Scripting

Read text from a file between two characters..

I have a requirement where i have to read from a .sh file a text lying bet characters like 'SELECT' & ';'...Please help me out in this. I am new to shell scripting. (2 Replies)
Discussion started by: goutam_igate
2 Replies

3. Shell Programming and Scripting

Replacing text/characters in vi

ok, so i have the following text to replace but it's not working. can someone please help me out: :%s~awk '// {split($2,s,",");a=$1 FS s} /-/ {b=a} END{print b}'~tail -1~g I want to replace the entire awk command with tail -1. thanks (7 Replies)
Discussion started by: SkySmart
7 Replies

4. UNIX for Dummies Questions & Answers

Help with deleting characters from text file

I have a text file that looks like this: I want to delete the last character of first column in all rows so that my output looks like this: Thanks a lot! (1 Reply)
Discussion started by: evelibertine
1 Replies

5. Shell Programming and Scripting

Remove characters from text

I have a file which looks like this. I only show first 11 lines of the file followed by some text that appears at the end of every file. 1. file:///path1/path2/path3/path4/251192.dat (score 3.849384, docid 142923) 2. file:///path1/path2/path3/path4/173859.dat (score 3.831033, docid 75365) 3.... (4 Replies)
Discussion started by: shoaibjameel123
4 Replies

6. Shell Programming and Scripting

wrapping text not exceeding 80 characters

I have a file where the text might exceed 80 characters. I want to have the maximum text lengths to be 80, and cut text from a space. I written an awk script below but does not seem to work very well { gsub("\t"," ") $0 = line $0 while (length <= WIDTH) { line = $0 ... (3 Replies)
Discussion started by: kristinu
3 Replies

7. UNIX for Dummies Questions & Answers

Any way to get rid of ^M characters in a text file using pr?

When I use vi to see what's in the file I get this: int add1(int x) {^M return x + 1;^M} ^Mint subtract1(int x) {^M return x - 1;^M} ^Mint double_it(int x) {^M return x * 2;^M} ^Mint halve_it(int x) {^Mreturn x / 2;^M} ^Mint main() {^M int myint;^M int result;^M ... (2 Replies)
Discussion started by: Nonito84
2 Replies

8. Shell Programming and Scripting

Check if the text file has more than 2 characters

Guys, I know that the below command will cut the 13th field from test.txt file awk -F"|" '{print $13}' test.txt The answer would be, CA CN Ohio If we see the 3 rd one, it has more than 2 characters. So i wanted to check this in if condition and i want to get the output if the 13th... (4 Replies)
Discussion started by: AraR87
4 Replies

9. UNIX for Dummies Questions & Answers

How to delete text between two characters in line?

Hi, I have a large text file with the following format: >gi|347545744|gb|JN204951.1| Dismorphia spio voucher 5 ATCAAATTCCTTCCTCTCCTTAAA >gi|17544664774|gb|WN204922.32| Rodapara nigens gene region CCGGGCAAATTCCTTCCTCTCCTTAAA >gi|555466400|gb|SG255122.8| Bombyx mandariana genbank 3... (1 Reply)
Discussion started by: euspilapteryx
1 Replies

10. Shell Programming and Scripting

Remove Special Characters Within Text

Hi, I have a "|" delimited file that is exported from a database. There is one column in the file which has description/comments entered by some application user. It has "Control-M" character and "New Line" character in between the text. Hence, when i export the data, this record with the new... (4 Replies)
Discussion started by: tarun.trehan
4 Replies
roffit(1)							   roffit Manual							 roffit(1)

NAME
roffit - convert nroff to HTML SYNOPSIS
roffit [options] < inputfile > outputfile DESCRIPTION
roffit converts the inputfile to outputfile. The inputfile must be an nroff formatted man page, and the outputfile will be an HTML docu- ment. OPTIONS
--bare The output HTML will not include any HTML, HEAD or BODY tags. Also not that when this is selected, there will be no inlined CSS but you will have to define the necessary classes yourself. --version Display version number and exit --mandir=<dir> Set a directory in which roffit will check for other man pages (in nroff [name].[num] format) that this one refers to. If found, a <a href> link will be made to that page with a html extension instead of the number. The file name in the generated link will be prefixed by the dir given with --hrefdir. This works for references specified as manpage(3) (within the emhpasis foformatting) and in a plain .BR section (often used in the SEE ALSO section). --hrefdir=<dir> Specify a directory to prefix generated href links created with the --mandir option. This defaults to ".". CSS CLASSES
h2.nroffsh The nroff ".SH" section. These are normally the "headlines" before each sub section within the man page. p.nroffip The nroff ".IP" section. These are normally the bullet kind used to list each option out of several in a list. Usually followed by a p.level0 containining the descriptive text. p.level0 Normal text at the first level. Normally not indented. p.level1 Text at next logical indent level. Normally indented one level right. p.level2 Text at the second logical indent level. Normally indented two levels right. span.bold Text marked to be bold. span.manpage Text marked as a reference to another man page. span.emphasis Text marked to be emphasized. p.roffit Used for the advertising final paragraph. WWW
http://daniel.haxx.se/projects/roffit roffit 0.6 27 Feb 2004 roffit(1)
All times are GMT -4. The time now is 05:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy