Align or move paragraph right


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Align or move paragraph right
# 15  
Old 03-21-2012
I believe you want to look to two different strings, one for paragraphs that need to be indented and one not indented:

Code:
printf "String for indented paragraphs: "
read indent
printf "String for other paragraphs: "
read other
nawk  -v indent="$indent" -v other="$other" '$0~indent { gsub(/\n/, "\n\t\t"); print "\t\t"$0} $0~other' RS= FS="\n" ORS="\n\n" IGNORECASE=1 infile

# 16  
Old 03-21-2012
Hello
what I am am trying to do is indent the paragraph containing OUT
and at the same time extract on any paragraph that contains both OUT and string (user input).
The NAWK works beautifully for indenting and extracting paragraphs containing OUT but when I try to introduce a variable from a user input(string), it dos not seem to recognize it.
If that clarify things.
Regards
# 17  
Old 03-22-2012
Seems to be working fine for me:

Code:
$ cat infile
Please ensure any expense claims are made
promptly as the evaluation period is about to expire.
 
Reading the operating instructions is
vital to the correct operation of this equipment.
 
Workstation serial numbers must be sent to the
purchasing department before equipment is distributed.
 
$ find=correct
$ awk  -v look="$find" '/claims/ { gsub(/\n/, "\n\t\t"); print "\t\t"$0} $0~look' RS= FS="\n" ORS="\n\n" IGNORECASE=1 infile
                Please ensure any expense claims are made
                promptly as the evaluation period is about to expire.
 
Reading the operating instructions is
vital to the correct operation of this equipment.

# 18  
Old 03-22-2012
Thanks again, I think it must be the way Iam trying to use the user input (there typed serached word) I may not be setting it right as the variable (string)

Code:
date=$( date +%d%m%y$h%m%s ) 
newfilename="testfile.$date" 
printf "enter filename: " 
read filename
printf "enter string: "
read string 
sed '/NZDT/{N;s/\n//;}' $filename >$newfilename
sleep 3
find=string
nawk -v look="$find" ' /OUT/ { gsub(/\n/, "\n\t\t"); print "\t\t"$0} $0~look' RS= FS="\n" ORS="\n\n" IGNORECASE=1 $newfilename



Sorry to take up your time with this, if there is something I am doing wrong with the variable please let me know, else thanks for replying and giving me the Nawk commands.


Last edited by Franklin52; 03-23-2012 at 04:57 AM.. Reason: Please use code tags for code and data samples, thank you
# 19  
Old 03-22-2012
this find=string should be find=$string
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