The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-21-2008
deepam deepam is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 4
Unhappy Help Me Please

I Have a file Say XYZ , I need a shell script in unix which will append 52 extra spaces at end of each line of the file excluding first and last line

Please help me out for the same

Last edited by deepam; 10-21-2008 at 05:26 AM..
  #2 (permalink)  
Old 10-21-2008
radoulov's Avatar
radoulov radoulov is online now Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,856
Code:
perl -i.bak -ple'$_.=" "x52unless$.==1||eof' XYZ

Last edited by radoulov; 10-21-2008 at 04:22 AM.. Reason: added -i :)
  #3 (permalink)  
Old 10-21-2008
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,082
below script will add four space together with 'end' at each line except first and last line. Hope can make sense to you.

Code:
sed '1 !{
  $ !{
    s/\(.*\)/\1        end/
  }
}' filename
  #4 (permalink)  
Old 10-21-2008
deepam deepam is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 4
Thanx for your needfull Help

Last edited by deepam; 10-21-2008 at 07:34 AM..
  #5 (permalink)  
Old 10-21-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
What do you think will you have to change in this script to add a "big number of spaces" instead of "4 spaces and 'end'"?

"do you think" is the key phrase here: the availability of our community and the willingness of us to helps others (you) out does not exempt you from the necessity to work yourself on a problem. Neither does it exempt you from getting knowledge about the tools used. We are gladly helping others to go if they are lying flat - but we will neither go for them nor carry them for any arbitrary time.

A second thing is: as we answer your and others questions here we are trying to build up a knowledge base. If someone else has a problem similar or equal to yours s/he should be able to search the archives and find this thread and use what we have written to you. What do you think, in light of this, is helping this cause when your problem description - the title of your thread - is "help me please". Why do you expect us to understand your problem and work out an answer if you are not even willing to understand and correctly phrase your problem much less solve it. You took the time to format your post fancily and put in some smilies, but you didn't take the time to think about what your problem really is. Think about your priorities, svp.

bakunin
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0