Visit The New, Modern Unix Linux Community

Top Forums UNIX for Dummies Questions & Answers End of line character in BAsh Post 43 by Rukshan on Wednesday 27th of September 2000 10:20:14 PM

I'm trying to match the end of line character in a shell script under bash. What I have done it got is a loop that reads each line of a file into a temp variable and then I get each letter of that variable and do some work on it. One think I want to do it check if the character I checking if the end of line character.

eg if [ $Letter5 = end of line ]
echo $tempWord

Test Your Knowledge in Computers #391
Difficulty: Medium
Darwin, the open source subset of macOS, has behavior that can be set to comply with UNIX 03.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

end of the line character

How do i determine what the end of the line character is in a text file. for eg. is it \n or \f or \t etc.. Is there a unix command for this? (5 Replies)
Discussion started by: zomboo
5 Replies

2. UNIX for Dummies Questions & Answers

stripping last character from end of each line

Hi, sorry for being dumb but I have a file with a variable amount of records (day to day it differs) but is fixed at 80 characters wide. Unfortunately the 80th and last charachter in each line is a "^M" carriage return character which i want to get rid of. Is there a really easy command that i can... (6 Replies)
Discussion started by: hcclnoodles
6 Replies

3. Shell Programming and Scripting

Removing character from list line (at the end)

Hi, I have file as shown below. abc, def, abc, xyz, I have to remove ',' from end of last line (xyz,). How can I do that with single command? Is it possible or I have to iterate through complete file to remove that? - Malay (2 Replies)
Discussion started by: malaymaru
2 Replies

4. UNIX for Advanced & Expert Users

Deleting end of line $ character in file

Hi, I've got a file where in the middle of the record is a $ end of line character, visible only when I open the file in vi and do :set list. How to I get rid of the character in the middle and keep it at the end. The middle $ character always appears after SW, so that can be used to tag it.... (3 Replies)
Discussion started by: bwrynz1
3 Replies

5. UNIX for Dummies Questions & Answers

How to add new line character at the end of a file

hi all, i have this question: How to add new line character at the end of a file???? i need this because i am loading a file to sybase and i have problems with the last record thanks for your help (5 Replies)
Discussion started by: DebianJ
5 Replies

6. Shell Programming and Scripting

add character to the end of each line in file

hi all i have 32 lines in file. the length of each line is 82 , i want that in the end of each line , means in postion 83-84 to put two characters 0d(=\015), 0a(=\012) i want that the 0d will be in postion 83 and the 0a will be in postion 84 in each line of the file how shall i do it ? ... (7 Replies)
Discussion started by: naamas03
7 Replies

7. Shell Programming and Scripting

add character to every end-of line in file

Hi All I have a file which conatins record.the length of every records is 47. problem : in the end of record i don't have a "\015" character. i want to add this "\015" charcter in the end of every record. the file contains something like 700 records. i've tried with sed command - nothing. ... (8 Replies)
Discussion started by: naamas03
8 Replies

8. Shell Programming and Scripting

Junk Character appended at the end of a line

Hi All I have a rather unusual problem, which i have not faced till now. I have a script which exports some paths to a text file. The script runs fine but when i check the output file i can see some junk characters ^M appended at end of lines and random places. I am not able to figure... (4 Replies)
Discussion started by: raghu_shekar
4 Replies

9. Shell Programming and Scripting

How to add a character at end of line?

Hai, I have got a small requirement in my script. and i am using bash shell. I need to add a dot (.) for some particular line in a file. Say for example, $Cat rmfile 1 This is line1 2 This is line2 3 This is line3 O/p should be : $Cat rmfile 1 This is line1 2 This is line2. #... (2 Replies)
Discussion started by: Sivajee
2 Replies

10. Shell Programming and Scripting

Conditionally add character at end of line

Hi, I would like have a shell script to check every line in a file to see if it ends with ";". If this is NOT the last character ";" should be added. MyFile.csv : web9331801;01/01/2014 23:39:35;;"93962";353150256; web9331802;01/01/2014 23:44:29;;"479288";353153538; web9331803;01/01/2014... (14 Replies)
Discussion started by: vg77
14 Replies
gets(n) 						       Tcl Built-In Commands							   gets(n)


gets - Read a line from a channel SYNOPSIS
gets channelId ?varName? _________________________________________________________________ DESCRIPTION
This command reads the next line from channelId, returns everything in the line up to (but not including) the end-of-line character(s), and discards the end-of-line character(s). ChannelId must be an identifier for an open channel such as the Tcl standard input channel (stdin), the return value from an invocation of open or socket, or the result of a channel creation command provided by a Tcl extension. The channel must have been opened for input. If varName is omitted the line is returned as the result of the command. If varName is specified then the line is placed in the variable by that name and the return value is a count of the number of characters returned. If end of file occurs while scanning for an end of line, the command returns whatever input is available up to the end of file. If chan- nelId is in nonblocking mode and there is not a full line of input available, the command returns an empty string and does not consume any input. If varName is specified and an empty string is returned in varName because of end-of-file or because of insufficient data in non- blocking mode, then the return count is -1. Note that if varName is not specified then the end-of-file and no-full-line-available cases can produce the same results as if there were an input line consisting only of the end-of-line character(s). The eof and fblocked commands can be used to distinguish these three cases. EXAMPLE
This example reads a file one line at a time and prints it out with the current line number attached to the start of each line. set chan [open "some.file.txt"] set lineNumber 0 while {[gets $chan line] >= 0} { puts "[incr lineNumber]: $line" } close $chan SEE ALSO
file(n), eof(n), fblocked(n), Tcl_StandardChannels(3) KEYWORDS
blocking, channel, end of file, end of line, line, nonblocking, read Tcl 7.5 gets(n)

Featured Tech Videos

All times are GMT -4. The time now is 11:43 AM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy