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
Need Urgent Help!!! Furqan_79 Shell Programming and Scripting 3 05-24-2008 07:33 PM
need urgent help namishtiwari Shell Programming and Scripting 10 02-18-2008 08:42 AM
Need urgent sed help bhatia333 Shell Programming and Scripting 6 06-07-2007 06:41 PM
URGENT,URGENT- Need help tape drive installation sriny UNIX for Advanced & Expert Users 3 11-16-2006 03:43 PM
URGENT---URGENT--No OK PROMPt after RSC CONFIG sriny SUN Solaris 7 10-29-2006 11:06 AM

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 Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
  #1 (permalink)  
Old 06-25-2008
arghya_owen arghya_owen is offline
Registered User
  
 

Join Date: May 2008
Posts: 31
Urgent

i have a serious simple problem.please help me out of the situation.
i hav a file which contains----

01473341234,
01473312121,
13131231233,
31233444555,
------------------------
data like that.i want to delete last line comma(,) only.what will be tha command.
  #2 (permalink)  
Old 06-25-2008
ynir ynir is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 35
a little complicated, but think it will do:
Code:
len=`cat aaa|wc -l`; sed -n "1,$[${len}-1]p"  aaa; tail -1 aaa |tr -d ','
run example:
Code:
# cat aaa
01473341234,
01473312121,
13131231233,
31233444555,

# len=`cat aaa|wc -l`; sed -n "1,$[${len}-1]p"  aaa; tail -1 aaa |tr -d ','
01473341234,
01473312121,
13131231233,
31233444555
  #3 (permalink)  
Old 06-25-2008
sanjaypraj sanjaypraj is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 7
The "file" contains the existing data.
sed '/^$/d' file > file1 // remove blank lines from the file
var=$(sed -n "`wc -l <file1`p" file1`) // to print the last line
echo ${var%*,} // remove the , from the end

Last edited by sanjaypraj; 06-25-2008 at 06:47 AM..
  #4 (permalink)  
Old 06-25-2008
arghya_owen arghya_owen is offline
Registered User
  
 

Join Date: May 2008
Posts: 31
easier one----------------

run example:
Code:
# cat aaa
01473341234,
01473312121,
13131231233,
31233444555,

# sed '$,$s/,/ /' aaa
01473341234,
01473312121,
13131231233,
31233444555
[/QUOTE]
  #5 (permalink)  
Old 06-25-2008
ynir ynir is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 35
excellent


a little improve:
Code:
# sed '$s/,//' aaa
01473341234,
01473312121,
13131231233,
31233444555
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 02:05 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