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.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Replacing a line in a file - HELP!!! maxmave Shell Programming and Scripting 1 06-04-2008 11:55 PM
Replacing end of line with " in a UNIX file The Observer Shell Programming and Scripting 2 05-17-2008 05:20 AM
replacing a line of unknown charecters in a file malavm Shell Programming and Scripting 12 07-26-2007 04:25 AM
Replacing characters in file with line break johnemb Shell Programming and Scripting 10 04-26-2007 07:38 AM
replacing first line or lines in a file Terrible UNIX for Advanced & Expert Users 3 06-28-2006 08:23 PM

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

Join Date: Jan 2008
Location: Bangalore,India
Posts: 144
Arrow Replacing the last data of each line ina file

Hi,

I ahve a file where the format is as given below:

qqq dfsf gdfjkg gjdosjg jkflsjd 21
fdksdlf fsdnkfl lkdfsgjld 45
laefsdl fsdlfksl fsdklflk gfsdl 56

I need to replace the last number by space or delete the last number in each line. (by using awk/sed/grep)

Can U please help me with this .

thanks in advance
Js
  #2 (permalink)  
Old 02-01-2008
panknil panknil is offline
Registered User
  
 

Join Date: Apr 2007
Location: Kolkata
Posts: 83
Thumbs up

Dear jisha,

u can try this

sed 's/[0-9]*$//' filename

Regards,
Pankaj
  #3 (permalink)  
Old 02-01-2008
jisha jisha is offline
Registered User
  
 

Join Date: Jan 2008
Location: Bangalore,India
Posts: 144
Thank you so much Pankaj
Its working
Js
  #4 (permalink)  
Old 07-30-2008
kranti hande kranti hande is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 1
hi
i m not geeting any command for writing data in any existing file at end
of file though linux commands.plz suggest me anything for it.

kranti
  #5 (permalink)  
Old 07-30-2008
BMDan BMDan is offline
Registered User
  
 

Join Date: Jul 2008
Location: BlackMesh Managed Hosting
Posts: 66
Quote:
Originally Posted by kranti hande View Post
hi
i m not geeting any command for writing data in any existing file at end
of file though linux commands.plz suggest me anything for it.

kranti
Parser failed; syntax error at line 1.
  #6 (permalink)  
Old 08-03-2008
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,078
Code:
awk '{for(i=1;i<=NF-1;i++){printf("%s ",$i)};print "";}' filename
  #7 (permalink)  
Old 08-04-2008
ynilesh's Avatar
ynilesh ynilesh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore, India.
Posts: 222
hello kranti,
You can just append command output to the file like,

Code:
command >> filename
- nilesh
Sponsored Links
Closed Thread

Bookmarks

Tags
linux commands

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 03:30 AM.


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