Sponsored Content
Top Forums Shell Programming and Scripting How to remove new line char from a string Post 302250214 by sreedivia on Wednesday 22nd of October 2008 11:52:59 PM
Old 10-23-2008
How to remove new line char from a string

Hi
Can anyone tell me how can i remove new line character from a string.
My requirement is to read a line from a file and store it to a string.
read line
string1=$line
read line
string2=$line
echo $string1$string2

The result i am getting in different line. i want the output in the same line.
I think a newline char is getting inserted into each string.How can i remove it?
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove Line that contains specific string

I am looking for a way to remove any line in a text file that contains the string "Mac address". I guess you would grep and sed, but I am not sure how to do this. Thanks for you help. (3 Replies)
Discussion started by: CBarraford
3 Replies

2. Shell Programming and Scripting

Help needed to remove a char from a specified sub-string

Hi! I'm having trouble usind sed to remove the char ' from within a database's varchar register's sql. For example, on the following sql: INSERT INTO patrimonio_municipal.patrimonio_municipal_airc_tmp Values('|Estação Elevatória|',|16723|,'|Grandes Reparações|', '|2010-03-26... (3 Replies)
Discussion started by: cremat0rio
3 Replies

3. Shell Programming and Scripting

Remove line based on string and put new line with parameter

Hi Folks, I am new to ksh, i have informatica parameter file that i need to update everyday with shell script. i need your help updating this file with new parameters. sample data $$TABLE1_DATE=04-27-2011 $$TABLE2_DATE=04-23-2011 $$TABLE3_DATE=03-19-2011 .......Highligned... (4 Replies)
Discussion started by: victor369
4 Replies

4. Shell Programming and Scripting

Remove last string from each line

I am trying to write a script that will allow me to recursively look at my directories, and output all filenames to a txt document. I am almost finished, however I am hitting one last snag. Here is my script so far: find . | grep .jpg | awk -F"/" '{print $NF}' > output.txtThis will give me an... (7 Replies)
Discussion started by: Davinator
7 Replies

5. UNIX for Dummies Questions & Answers

Remove First Char from Line in File Only if it's a comma

I have a file, I need to remove the first character of each line, but only if it's a comma. I don't want to delete any other commas in each line. Trying cat or sed but I really don't know them very well, would love some help. This removes the first comma, but it removes the first comma no... (6 Replies)
Discussion started by: Cynthia
6 Replies

6. Shell Programming and Scripting

How to remove the # char form a line?

Hi, my file has below details and I want remove the # char from only specific line. #TEST:00:START #TEST1:01:INPROCESS #TEST2:02:ABOUTTO #TEST3:03:COMP i.e if want remove the # from 2nd line then file to be updated as #TEST:00:START TEST1:01:INPROCESS #TEST2:02:ABOUTTO... (6 Replies)
Discussion started by: sandyrajh
6 Replies

7. Shell Programming and Scripting

Remove only specific char on every line when exists

Hi I need to remove "|" char when it's the last char of the line. Input file: generoso|desprendido|altruista| abnegar|ceder|sacrificar| abocetado-da|esbozado| apuntado|insinuado|incompleto abocetar|esbozar|bosquejar| diseñar|delinear ------------------------ output need --- ... (11 Replies)
Discussion started by: lookoo
11 Replies

8. Shell Programming and Scripting

Remove every line with specific string, and also the one above and below it

I would like to identify every line with a specific string, in this case: "Mamma". I would like to remove that line, and also the line above it and below it. So the below Where are all amazing Flats Look At The Great Big White Hey There Hot Mamma You Are So hot Baby I wish You were Mine... (5 Replies)
Discussion started by: phpchick
5 Replies

9. UNIX for Advanced & Expert Users

Vi remove line range containing a string

In vi I would like to remove a line containing a string. I thought after reading this I could do this. https://www.unix.com/302297288-post3.html :'3560,3572/gcc/d' It keeps complaining vi mark not set. And sometimes it complains E488: Trailing characters. I don't understand what mark... (5 Replies)
Discussion started by: cokedude
5 Replies
sem_unlink(2)							System Calls Manual						     sem_unlink(2)

NAME
sem_unlink - unlink a named POSIX semaphore SYNOPSIS
DESCRIPTION
is used to unlink named semaphores. A successful call to marks the semaphore, specified by name, for removal. Calling does not affect processes, including the calling process, which currently have a descriptor, obtained from a call to Named semaphores are uniquely identi- fied by character strings. All character string names will be pre-processed to ensure variations of a pathname resolve to the same sema- phore name. If the semaphore is successfully marked for removal by a call to the semaphore will be removed when all processes remove their descriptors to the specified semaphore by calling Subsequent calls to using the string name will refer to a new semaphore. To use this function, link in the realtime library by specifying on the compiler or linker command line. EXAMPLES
The following call to will remove the named semaphore named by the string name. If the semaphore is currently referenced by one or more processes, the semaphore will be marked for removal and removed when there are no more processes referencing it. RETURN VALUE
If the semaphore was unlinked successfully, returns 0. If the semaphore could not be unlinked, the call returns -1 and sets to indicate the error. ERRORS
fails and does not perform the requested operation if any of the following conditions are encountered: [EACCES] The named semaphore exists and the process does not have the permissions to unlink the semaphore. [ENAMETOOLONG] The name string is longer than [ENOENT] The flag is not set in oflag (see sem_open(2)) and the named semaphore does not exist. SEE ALSO
sem_close(2), sem_open(2), privileges(5), <semaphore.h>. STANDARDS CONFORMANCE
sem_unlink(2)
All times are GMT -4. The time now is 05:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy