Sponsored Content
Top Forums Shell Programming and Scripting Adding tab/new line at the end of each line of a file Post 302686673 by Sourav Das on Wednesday 15th of August 2012 08:29:02 AM
Old 08-15-2012
Thanks for your reply ..
Eventhough I used "$RSUFFIX" , I am not seeing any change in my output i.e. no char are appended to the last line of each record.

Below is my current code and I am executing the following , from the command line ( ./SampleScript.sh '\\t' )

SampleScript.sh ->
Code:
#!/bin/ksh
#================================#
# Script to change the #
# delimiter of any file and #
# also zip the file #
#================================#
NOW=`date '+%Y%m%d%H%M'`
NOW_DATE=`date '+%Y%m%d'`
RSUFFIX=$1
echo "==============================="
echo "$NOW"
echo "$RSUFFIX"
echo "===================="
rm TEMP1.txt
rm TEMP2.txt
touch TEMP1.txt
touch TEMP2.txt
echo "$RSUFFIX"
nawk -v rsuffix="$RSUFFIX" 'BEGIN { print rsuffix }'
##======== This doesn't work =============================
 awk '{print $0 rsuffix}' TESTDATA.txt > TEMP1.txt
##======== This works =============================
 awk '{print $0 "\t\t"}' TESTDATA.txt > TEMP2.txt

My expected Result is
Code:
137798|Sourav_Das|100<one tab>     
127798|S_Das|101<one tab>
117798|S.Das|1<one tab>


Last edited by Franklin52; 08-15-2012 at 09:55 AM.. Reason: Please use code tags for data and code samples
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

adding text to end of each line in a file

I'm needing to add a "hour:min" to the end of each line in a document. The document in this case is only going to be one line. if this inserts it at the end, what needs to be changed to add something at the end... /bin/echo "%s/^/$filler/g\nwq!" | ex -s $oFile Thank you... (2 Replies)
Discussion started by: cubs0729
2 Replies

2. Shell Programming and Scripting

Grabing Date from filename and adding to the end of each line in the file.

Hi, I have 24 .dat files something like below. The file name starts with “abc” followed by two digit month and two digit year. Is there a way to grab the month and year from each filename and append it to the end of each line. Once this is done I want to combine all the files into file... (1 Reply)
Discussion started by: rkumar28
1 Replies

3. Shell Programming and Scripting

Adding new line at the end of file

Hi I have few files. For some files the cursor is at the end of last line. For other files, cursor is at the new line at the end. I want to bring the cursor down to next line for the files that are having cursor at the end of last line In otherwords, I want to introduce a blank line at the... (5 Replies)
Discussion started by: somesh_p
5 Replies

4. Shell Programming and Scripting

Adding multiple line at the end of the file

I have 2 files which contains the following lines file1.txt line4 line5 line6 file2.txt line1 line2 line3 When i execute a script , I want my file2.txt will looks like this: line1 line2 line3 line4 line5 (2 Replies)
Discussion started by: kaibiganmi
2 Replies

5. Shell Programming and Scripting

adding characters end of line where line begins with..

Hi all, using VI, can anyone tell me how to add some characters onto the end of a line where the line begins with certain charactars eg a,b,c,......., r,s,t,........, a,b,c,......., all lines in the above example starting with a,b,c, I want to add an x at the end of the line so the... (6 Replies)
Discussion started by: satnamx
6 Replies

6. Shell Programming and Scripting

help with sed adding line to end of file

sed '$a\ hello' books hi i am trying to use sed to append hello to the end of the file books, but for some reason i can't get it work. It keeps sayin command garbled. Anyone know what I'm doing wrong. this is in a ksh script as well. (3 Replies)
Discussion started by: bjhum33
3 Replies

7. Shell Programming and Scripting

adding line number to *end* of records in file

Given a file like this: abc def ghi I need to get to somestandardtext abc1 morestandardtext somestandardtext def2 morestandardtext somestandardtext ghi3 morestandardtext Notice that in addition to the standard text there is the line number added in as well. What I conceived is... (4 Replies)
Discussion started by: edstevens
4 Replies

8. Shell Programming and Scripting

Adding text to the end of the specific line in a file(only to the first occurrence of it)

Hi, I want to add a text to the end of the specific line in a file. Now my file looks like this: 999 111 222 333 111 444 I want to add the string " 555" to the end of the first line contaning 111. Moreover, I want to insert a newline after this line containg the "000" string. The... (8 Replies)
Discussion started by: wenclu
8 Replies

9. Shell Programming and Scripting

Help on Adding one counter loop at the end of each line in a file

Hello All, I have file a.txt I want to add a counter loop at the end of each line in a file ill explain: i have a site h**p://test.test=Elite#1 i want to add a a counter to the number at the end of the file, that it will be like this urlLink//test.test=Elite#1 urlLink//test.test=Elite#2... (3 Replies)
Discussion started by: nexsus
3 Replies

10. Shell Programming and Scripting

Adding comma to end of each line if more than 1 line

I have a file with dates as '2013-01-01' '2013-01-02' I want the output to be '2013-01-01','2013-01-02' if there is only 1 entry then there should not be any comma. (6 Replies)
Discussion started by: ATWC
6 Replies
RADEAPCLIENT(1) 						 FreeRADIUS Daemon						   RADEAPCLIENT(1)

NAME
radeapclient - send EAP packets to a RADIUS server, calculate responses SYNOPSIS
radeapclient [-c count] [-d raddb_directory] [-f file] [-h] [-i source_ip] [-q] [-s] [-r retries] [-S file] [-t timeout] [-v] [-x] server {acct|auth} secret DESCRIPTION
radeapclient is a radius client program. It can send arbitrary radius packets to a radius server, then shows the reply. Radeapclient dif- fers from radclient in that if there is an EAP-MD5 challenge, then it will be responded to. radeapclient is otherwise identical to radclient. The EAP-Identity attribute, if present is used to construct an EAP Identity message. The EAP-MD5-Password attribute, if present is used to respond to an MD5 challenge. No other EAP types are currently supported. OPTIONS
-c count Send each packet count times. -d raddb Set dictionary directory. -f file Read packets from file, not stdin. -r retries If timeout, retry sending the packet retries times. -t timeout Wait timeout seconds before retrying (may be a floating point number). -h Print usage help information. -i id Set request id to 'id'. Values may be 0..255 -S file Read secret from file, not command line. -q Quiet, do not print anything out. -s Print out summary information of auth results. -v Show program version information. -x Enable debugging mode. EXAMPLE
A sample session that queries the remote server with an EAP-MD5 challenge. ( echo 'User-Name = "bob"'; echo 'EAP-MD5-Password = "hello"'; echo 'NAS-IP-Address = marajade.sandelman.ottawa.on.c'; echo 'EAP-Code = Response'; echo 'EAP-Id = 210'; echo 'EAP-Type-Identity = "bob"; echo 'Message-Authenticator = 0x00'; echo 'NAS-Port = 0' ) >req.txt radeapclient -x localhost auth testing123 <req.txt SEE ALSO
radclient(1) AUTHOR
Michael Richardson, <mcr@sandelman.ottawa.on.ca> 08 September 2003 RADEAPCLIENT(1)
All times are GMT -4. The time now is 04:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy