![]() |
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 |
| Append each line to next previous line in a file | sudhakaryadav | Shell Programming and Scripting | 8 | 06-01-2009 11:21 AM |
| Append line that does not contain pipe to it previous line | ainuddin | Shell Programming and Scripting | 11 | 11-11-2008 10:58 AM |
| Joining lines in reverse. append line 1 to line 2. | dwalley | Shell Programming and Scripting | 7 | 08-04-2008 07:11 AM |
| How to append some strings line by line? | xinoo | Shell Programming and Scripting | 4 | 06-24-2008 02:04 AM |
| append a line to the last line in a file | subhrap.das | UNIX Desktop for Dummies Questions & Answers | 5 | 04-25-2007 09:17 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
thanks it works..
I also like to know i am getting some value into a variable using grep command Code:
count_trlr=`grep "^3" $DATADIR/$FILE1.DAT| cut -c2-8` eg: count_trlr=000004 but i want only the number 4 not zeroes like this, count_trlr=4 Code:
eg: contr_trlr=0023343, i want 23343 contr_trlr=1111111, i want 1111111 contr_trlr=0222222, i want only 222222 thanks in adv. |
|
||||
|
Code:
$ cat FILE1.TXT
2293847982374 sdj 23423
2298372038974 dsj 23492
2972837629376 abj 34929
2984836398384 abc 39723
$ cat ./add_trailer.ksh
#!/bin/ksh
MYFILE=FILE1.TXT
FILECOUNT=$(wc -l < $MYFILE 2>/dev/null)
typeset -Z6 TRAILER=${FILECOUNT:-0}
echo "3$TRAILER" >> $MYFILE
exit 0
$ ./add_trailer.ksh
$ cat FILE1.TXT
2293847982374 sdj 23423
2298372038974 dsj 23492
2972837629376 abj 34929
2984836398384 abc 39723
3000004
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|