Allignment of lines in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Allignment of lines in a file
# 1  
Old 07-30-2009
Allignment of lines in a file

Hi All,

I am using the below scrit to insert lines in a file:

Code:
#!/bin/ksh
# To delete the last line if it contains the pattern Redirect permanent / Virgin Atlantic Airways - Popup
echo "Enter the URL that should point to the particular microsite"
read url
# To delete the last line if it contains the pattern Redirect permanent / Virgin Atlantic Airways - Popup
if [ -z "$value" ]; then
echo "You have not enterd the URL" ; exit 1
else
grep "Redirect permanent / http://www.virgin-atlantic.com" redirects.virgin-atlantic.com.conf > output1
if [ $? -eq 0 ] ; then
rm -r output1
sed '$d' redirects.virgin-atlantic.com.conf > temp
cp temp redirects.virgin-atlantic.com.conf
echo $url >> redirects.virgin-atlantic.com.conf ;
echo "Redirect permanent / http://www.virgin-atlantic.com" >> redirects.virgin-atlantic.com.conf ;
echo "Redirects Setup"
else
echo $url >> redirects.virgin-atlantic.com.conf ;
echo "Redirects Setup"
fi
fi

I am getting the below output where the 2,3,4 line are in the same line whereas 5 and 6 are the lines that are inserted by using the script. Please can somebody advise how can I insert the 5 and 6 line so that they are alligned with the above lines.


Redirect permanent /threadneedle Virgin Atlantic Airways - Popup
Redirect permanent /THREADNEEDLE Virgin Atlantic Airways - Popup
Redirect permanent /vhipprize http://ad.uk.doubleclick.net
Redirect permanent /lovefromabove http://www.virgin-atlantic.comp
Redirect permanent /shazin Virgin Atlantic Airways - Popup
Redirect permanent /shaz Virgin Atlantic Airways - Popup

Best Regards,
Shazin

---------- Post updated at 09:08 PM ---------- Previous update was at 09:05 PM ----------

Hio All,

Its not coming as required please can somebody suggest so that i can upload a txt file describing the output.

Thanks
Shazin

Last edited by vidyadhar85; 07-30-2009 at 02:43 PM..
# 2  
Old 07-30-2009
from where $value came into picture???
Quote:
if [ -z "$value" ]; then
# 3  
Old 07-30-2009
Without going into details of your script (needs lot of fixes):
Just quote all your echo statements with " " :
Code:
echo "$url"

If there are multiple spaces this will help.

Also, if you are unable to attach file then use the CODE option just like what you did for your script. And choose font as "Courier New". That should take care of the "alliginment".

Like this:
Code:
 
Redirect permanent /threadneedle  Virgin Atlantic Airways - Popup
Redirect permanent /THREADNEEDLE  Virgin Atlantic Airways - Popup
Redirect permanent /vhipprize     http://ad.uk.doubleclick.net
Redirect permanent /lovefromabove http://www.virgin-atlantic.comp
Redirect permanent /shazin        Virgin Atlantic Airways - Popup
Redirect permanent /shaz          Virgin Atlantic Airways - Popup

Also, I think this line needs a fix?
Code:
if [ -z "$value" ]; then
if [ -z "$url" ]; then

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find all lines in file such that each word on that line appears in at least n lines of the file

I have a file where every line includes four expressions with a caret in the middle (plus some other "words" or fields, always separated by spaces). I would like to extract from this file, all those lines such that each of the four expressions containing a caret appears in at least four different... (9 Replies)
Discussion started by: uncleMonty
9 Replies

2. Shell Programming and Scripting

Allignment input file

Guys, I have a requirement as below 36%/ 55%/var 82%/tmp 74%/opt now i want the output to be --------------------------------- Disk% Mount --------------------------------- 36% / 55% var 82% tmp 74% opt ---------------------------------------- I have used... (3 Replies)
Discussion started by: AraR87
3 Replies

3. Shell Programming and Scripting

awk - script help: column to row format of data allignment?

Experts Good day, I have the following data, file1 BRAAGRP1 A2X B2X C2X D2X BRBGRP12 A3X B3X Z10 D09 BRC1GRP2 LO01 (4 Replies)
Discussion started by: rveri
4 Replies

4. UNIX for Advanced & Expert Users

SQL script with 86000 lines: new files with only 10000 lines (per file)

Hi this is my SQL script $ wc -l insert_into_customers.sql 85601 insert_into_customers.sqlI wish to cut this file into 9 files each 10000 lines (the last one less) $ wc -l insert_into_customers_00*.sql 10000 insert_into_customers_001.sql 10000 insert_into_customers_002.sql ... (1 Reply)
Discussion started by: slashdotweenie
1 Replies

5. Shell Programming and Scripting

Extract some lines from one file and add those lines to current file

hi, i have two files. file1.sh echo "unix" echo "linux" file2.sh echo "unix linux forums" now the output i need is $./file2.sh unix linux forums (3 Replies)
Discussion started by: snreddy_gopu
3 Replies

6. Shell Programming and Scripting

Output allignment

Hi Guys, I hope you are doing good out there. I am facing some issues in the alligment of the output of a shell script. Below is the statement which is formatting the output:echo $File | awk -F '' '{print $13,$15="\t"$16,$4="",$5,$6,$7}' and its output is Domain Log file ... (2 Replies)
Discussion started by: singh.chandan18
2 Replies

7. Shell Programming and Scripting

Text allignment using PERL

Hi Friends, For daily reports i make perl script like below. @dirlist = `cat out.txt |cut -d "|" -f1 >create.txt`; @dirlist1 = `cat out.txt|wc -l *e* >create2.txt`; open FILE, ">OUTPUT.txt"; @command = `cat out.txt |cut -d "|" -f1`; print FILE map{$_-2 ."\n"}@command; @dirlist2 =... (1 Reply)
Discussion started by: adaleru
1 Replies

8. Shell Programming and Scripting

linux 'paste' allignment problem

Hi Everyone, # cat 1 #!/usr/bin/perl print "c\tc\t\n"; # cat 2 #!/usr/bin/perl print "b\tb\t\n"; print "b\tb\t\n"; print "b\tb\t\n"; # perl 1 > 11 # perl 2 > 22 # cat 11 c c # cat 22 b b b b b b # paste 11 22 (5 Replies)
Discussion started by: jimmy_y
5 Replies

9. Shell Programming and Scripting

Allignment

Hi All, I want to shift the last and second last line to 8 spaces in the right inside a file. please can somebody suggest a script for the same. Thanks and Best Regards, Shazin (22 Replies)
Discussion started by: Shazin
22 Replies

10. Shell Programming and Scripting

Extra/parse lines from a file between unque lines through the file

I need help to parse a file where there are many records, all of which are consistently separated by lines containing “^=============” and "^ End of Report". Example: ============= 1 2 3 4 End of record ============= 1 3 4 End of record Etc.... I only need specific lines... (5 Replies)
Discussion started by: jouuu
5 Replies
Login or Register to Ask a Question