sed command to arrange words


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed command to arrange words
# 8  
Old 10-03-2015
Not sed, but this awk alternative also works with your given input.
Code:
awk '{$1=$1}1' RS= file

Note: it only works if there are two consecutive newlines (a completely empty line) between two vertical sentences, as is the case in your sample.
# 9  
Old 10-03-2015
Hi,
Another way in bash builtin works with your given input (for fun):
Code:
while read -d \. foo ; do echo $foo.; done <file ; [ "$foo" ] && echo $foo

Regards.
# 10  
Old 10-03-2015
An alternative in Perl.
Code:
perl -00 -nae 'print "@F\n"' my_Perl.file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Arrange output of a command

Hi, I am using a command :- ps -auxwww 2> /dev/null | awk 'match ($0, GIN:*/) {print substr($0, RSTART+3, RLENGTH-3)}' | sort | grep -v -F 'which gives output as 3 aruau 5 asun 4 cgan Now I need a command which gives me something like this :- 3 aruau 5 asun 4 cgan... (2 Replies)
Discussion started by: Raj999
2 Replies

2. Shell Programming and Scripting

Reverse words with sed

Hi guys, I'm wondering what the best way would be to reverse words in a string based on certain characters. For example: echo Word1Word2Word3Word4 | sed ' /\n/ !G s/\(Word.\)\(.*\n\)/&\2\1/ //D ' This returns: Word4Word3Word2Word1 I'm no sed expert but... (2 Replies)
Discussion started by: Subbeh
2 Replies

3. Shell Programming and Scripting

Swap words using sed

Hi. I have to swap the first and the third word in all lines of a txt file using sed. Separators between words are: any charachter, except intervall. I hope, you'll understand what I want to do. my english is not so good, sorry for that:) (10 Replies)
Discussion started by: T720
10 Replies

4. Shell Programming and Scripting

How to words in arrange as Table

Hi Team, I have one file in that almost 100+ words in lines Eg:- Unix windows solaris Linux ... ... But I want arrange all lines in table format and can able read on screen Eg: - Unix windows solaris Lunix...... Hp unix Mac-os ...... Like as Table...... (11 Replies)
Discussion started by: Bhaskar Alagala
11 Replies

5. Shell Programming and Scripting

Find and arrange words with same letters from list

I am making a word game and I am wondering how to find and arrange words in a list that have the same letters. In my game, you are presented with 5 letters, and you then have to rearrange the letters tp make a word. So the word could be "acorn", but those 5 letters could also make up "narco" or... (2 Replies)
Discussion started by: hellobard
2 Replies

6. Shell Programming and Scripting

SED - delete words between two possible words

Hi all, I want to make an script using sed that removes everything between 'begin' (including the line that has it) and 'end1' or 'end2', not removing this line. Let me paste an 2 examples: anything before any string begin few lines of content end1 anything after anything before any... (4 Replies)
Discussion started by: meuser
4 Replies

7. Shell Programming and Scripting

arrange merged data using sed

hi, i used paste file1.txt file2.txt > file3.txt to merge 2 columns from file1 and 4 columns from file2. file1 scaffold_217 scaffold_217 file2 CHRSM N scaffold_217.pf scaffold_217.fsa the result is as follows:- scaffold_217 scaffold_217 CHRSM ... (6 Replies)
Discussion started by: redse171
6 Replies

8. Shell Programming and Scripting

deleting blank line and row containing certain words in single sed command

Hi Is it possible to do the following in a single command /usr/xpg4/bin/sed -e '/rows selected/d' /aemu/CALLAUTO/callauto.txt > /aemu/CALLAUTO/callautonew.txt /usr/xpg4/bin/sed -e '/^$/d' /aemu/CALLAUTO/callautonew.txt > /aemu/CALLAUTO/callauto_new.txt exit (1 Reply)
Discussion started by: aemunathan
1 Replies

9. Shell Programming and Scripting

search two words in sed

I've following sed command working fine - sed '/search_pattern1/ !s/pattern1/pattern2/" file Now, I want to search two patterns - search_pattern1 and search_pattern2 . How can put these into above sed statement ? Thanks in advance. (12 Replies)
Discussion started by: ajitkumar2
12 Replies

10. UNIX for Dummies Questions & Answers

sed [delete everything between two words]

Hi, I have the following codes below that aims to delete every words between two pattern word. Say I have the files To delete every word between WISH_LIST=" and " I used the below codes (but its not working): #!/bin/sh sed ' /WISH_LIST=\"/ { N /\n.*\"/ {... (3 Replies)
Discussion started by: Orbix
3 Replies
Login or Register to Ask a Question