Align or move paragraph right


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Align or move paragraph right
# 1  
Old 03-17-2012
Question Align or move paragraph right

Hello I am a newbie in scripting and I am hoping someone may help with a method of aligning or tabbing selected text as its output.

For example, using the SED command to extract paragraphs containing AA BBB CCC

Code:
sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;/BBB/!d;/CCC/!d'

How could I say, get the output of BBB to align right with the
output?

Align might not be the right word but certainly move or tab right
output of a BBB while keeping the outputs of AAA and CCC on the left.

Thankyou for any help with this
Regards

Last edited by Franklin52; 03-19-2012 at 04:27 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 03-17-2012
You need to provide some sample inputs and desired outputs!

--ahamed
# 3  
Old 03-17-2012
Hello yes apologies, I am trying to align or offset a paragraph slightly - either center or by a few spaces.
For example on these searched AAA BBB CCC strings . I would like the desired output after running the above SED command (which extracts those searched strings and prints the whole paragraph where they are found). To look like this
AAA
BBB
CCC

Thankyou

---------- Post updated at 09:07 AM ---------- Previous update was at 09:05 AM ----------

Looks like the my message did not come out right - my blank spaces seemed to get ignored. Here it is again with underscores for blank spaces.
AAA
___BBB
CCC
# 4  
Old 03-17-2012
I still didn't get your requirement. Smilie
It would be better if you post the actual paragraph, search string and the desired output.

--ahamed
# 5  
Old 03-17-2012
Yes sorry hard to demonstrate, here is some more example.
If I have a file which I want to search for patterns located in paragraphs patterns - bobby, larry, sally. using command
Code:
sed -e '/./{H;$!d;}' -e 'x;/bobby/!d;/larry/!d;/sally/!d'

I get an output with all paragraphs containing these patterns like this

Bobby is 8 years old
and now gos to school.

Larry is 6 years old and
has just started school.

Sally is 7 and
she likes school alot.

Larry favorite subject is
PE as he gets to play soccer.

I would like to offset or center paragraphs using SED containing "Larry" so it looks like this a

Bobby is 8 years old
and now gos to school.
Larry is 6 years old and
has just started school.
Sally is 7 and
she likes school alot.
Larry favorite subject is
PE as he gets to play soccer.
Thankyou for any help

Last edited by Franklin52; 03-22-2012 at 04:19 AM.. Reason: Please use code tags for code and data samples, thank you
# 6  
Old 03-17-2012
Code:
awk 'f&&/^ *$/{f=0}/Larry/{f=1}f{printf "\t"}1' infile

infile will have the contents you have displayed.

--ahamed
# 7  
Old 03-18-2012
Thankyou very much I will try this.
Kind regards

---------- Post updated 03-19-12 at 10:33 AM ---------- Previous update was 03-18-12 at 11:30 AM ----------

Thanyou, I tried this but the awk errored
syntax error near line 1
bailing out near line 1

I wonder if its because in my above paragraph example I put the searched words as the beginning of the paragraph.
In my real case the searched words fall on the second line or could be anywhere within the paragraph.

Is there anyway to add to my SED command to achieve this - thankyou again.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Align columns

I have a text file that I filtered using awk. I only exctracted two columns. I want those two columns to be aligned. Most of the answers I found was to use `column -t` command. I tried that but I am getting a `bash: column: command not found`. Is there another way to align columns... (1 Reply)
Discussion started by: erin00
1 Replies

2. Shell Programming and Scripting

Re align in one row using sed

Hi, Anyone can help on how to re align my data in one row using sed. test.csv "url1","abc","project url1" 2016-08-16 "url2,"microsoft","project url2" 2016-08-18 need output like this "url1","abc","project url1","2016-08-16" "url2,"microsoft","project url2","2016-08-18" Thanks in... (8 Replies)
Discussion started by: fspalero
8 Replies

3. Shell Programming and Scripting

Align input fields on one under each other

Hello again, I'm having a issue with a contact form. I want the input fields to be aligned on same row and I really dont know how to do it. I attached a image for you to understand what i am trying to do. <BR> <label for="name" class="required"> Name&nbsp;<strong... (1 Reply)
Discussion started by: galford
1 Replies

4. Shell Programming and Scripting

Align columns

Hi, I have a question on how to align columns in shellscipt. SAMPLE 2015-07-15 09:01:00.0 |TCSERVER01 |10965 2015-07-15 09:02:00.0 |TCSERVER01 |4752 2015-07-15 09:03:00.0 |TCSERVER01 |4805 2015-07-15 09:04:00.0 |TCSERVER01 |3690 2015-07-15 09:01:00.0 |TCSERVER02 |8703 2015-07-15... (1 Reply)
Discussion started by: reignangel2003
1 Replies

5. Shell Programming and Scripting

Align data of the paragraph

Hi, I need your help to align data from paragraph. It's to : - delete the lign contain NDS - align data between paragraph start to "ND=" from second "ND=" example of file: @ ABOIL; @ CEN=1/15-05-23/09 H 06 MN 18/LISTAGE CARACTERISTIQUES D'ABONNES TRAITEMENT TGLAIL ACC... (1 Reply)
Discussion started by: vremen3
1 Replies

6. Shell Programming and Scripting

Better Align--output of find command

Hi, i have sh program which search for a file in a folder structure and provides its path. This is just used to see if that file exits more that once anywhere down the folder structure. I have used find command to search & printing it output on terminal. I have attached screen shot of it.... (10 Replies)
Discussion started by: praveenkumar198
10 Replies

7. Shell Programming and Scripting

Align with printf or other method

below line is one by one print audio_play PASS boot_check FAIL ethernet_change_mac NIC_82574L PASS gps_ublox_neo FAIL storage_bonnie USB2 PASS storage_copy_big_file USB2 PASS I would like below format ... (7 Replies)
Discussion started by: yanglei_fage
7 Replies

8. Shell Programming and Scripting

Align the words

HI , I am new to shell scripting i m getting the below format like this Name FirstName Lastname ------ --------- ---------- Name1 Balaji NandaKishore Name123 Vijaya krsihna ... (5 Replies)
Discussion started by: Lucky123
5 Replies

9. UNIX for Dummies Questions & Answers

Output text from 1st paragraph in file w/ a specific string through last paragraph of file w/ string

Hi, I'm trying to output all text from the first paragraph in a file that contains a specific string through the last paragraph in that file that contains that string. Previously, I was outputting just each paragraph with that search string with: cat in_file | nawk '{RS=""; FS="\n";... (2 Replies)
Discussion started by: carpenn
2 Replies

10. UNIX for Dummies Questions & Answers

Align Text from a file.

I need to align text from a file that has columns seperated by spaces and commas. Any ideas? Text is similar to this. File Name is Test. 05/14/06 13:46:56.575 ,TEST,5,123,1234,123,12345,12,12.2,2.1,4.5,5.23 05/14/06 13:49:58.009 ,TEST,6,456,456.7,45,4.56,453,34,54.3,3.2,6.456 (9 Replies)
Discussion started by: earlepps
9 Replies
Login or Register to Ask a Question