![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
||||
|
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. |
|
||||
|
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 ','
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
|
|
||||
|
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.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|