Sponsored Content
Top Forums Shell Programming and Scripting Removal of multiple characters with in double quotes Post 303011020 by Jag_1981 on Thursday 11th of January 2018 10:18:19 PM
Old 01-11-2018
Question Removal of multiple characters with in double quotes

For one of my need I was going through post "Removal of new line character in double quotes"

Which alister has replied like

Code:
$ cat data
"leave me alone"

"ABCD RENT-A-
CAR XYZ LTD","00N0H","Enterprise Lake","
100 View Way"
$ sed -n 'H;g;/^[^"]*"[^"]*\("[^"]*"[^"]*\)*$/d; s/^\n//; y/\n/ /; p; s/.*//; h' data
"leave me alone"

"ABCD RENT-A- CAR XYZ LTD","00N0H","Enterprise Lake"," 100 View Way"

In my case requirement is to remove new line character as well as pipe (|) character when it is present inside double quotes. So for that how to enhance this code snippet. I am new to to this area and unable to under stand how mentioned code snippet work. Thanks for any help.
Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, output, and code segments (as required by forum rules).

Last edited by Don Cragun; 01-12-2018 at 12:45 AM.. Reason: Add CODE tags and link to referenced thread.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace multiple blanks within double quotes

I have various column names within double quotes, separated by commas. Example: "column one", "column number two", "this is column number three", anothercolumn, yetanothercolumn I need to eliminate the double quotes and replace the blanks within the double quotes by underscores, giving: ... (5 Replies)
Discussion started by: jgrogan
5 Replies

2. Shell Programming and Scripting

Removal of comma(,) present inbetween double quotes(" ")

Hi Experts, I have a file with some of the records contain double quotes. If I found a double quote(") in any particular record , I need to look for the next double quote in that particular record and in between these quotes, if any comma(,) is there I need to replace with Tilde (~) in the same... (12 Replies)
Discussion started by: vsairam
12 Replies

3. Shell Programming and Scripting

Removal of new line character in double quotes

Hi, Could you please help me in removal of newline chracter present in between the double quotes and replacing it with space. For example ... Every field is wrapped with double quotes with comma delimiter, so I need to travese from first double quote occerence to till second double... (7 Replies)
Discussion started by: vsairam
7 Replies

4. UNIX for Dummies Questions & Answers

grep single quotes or double quotes

Unix superusers, I am new to unix but would like to learn more about grep. I am very familiar with regular expressions as i have used them for searching text files in windows based text editors. Since I am not very familiar with Unix, I dont understand when one should use GREP with the... (2 Replies)
Discussion started by: george_vandelet
2 Replies

5. UNIX for Dummies Questions & Answers

how to use grep: finding a string with double quotes and multiple digits

I have a file with a lot of lines (a lot!) that contain 10 digits between double quotes. ie "1726937489". The digits are random throughout, but always contain ten digits. I can not for the life of me, (via scouring the internet and grep how-to manuals) figure out how to find this when I search.... (3 Replies)
Discussion started by: titusbass
3 Replies

6. Shell Programming and Scripting

Multiple double quotes

hi Need to run below command on remote server: cmd -a "1 2" -b 3 If i run below, there's clash matching double quotes and fail. ssh $server "cmd -a "1 2" -b 3" I have few ideas which worked (like keeping the entire cmd in a file and copy it to remote server and then run that file)... (1 Reply)
Discussion started by: reddyr
1 Replies

7. Shell Programming and Scripting

Issue with Single Quotes and Double Quotes for prompt PS1

Hi, Trying to change the prompt. I have the following code. export PS1=' <${USER}@`hostname -s`>$ ' The hostname is not displayed <abc@`hostname -s`>$ uname -a AIX xyz 1 6 00F736154C00 <adcwl4h@`hostname -s`>$ If I use double quotes, then the hostname is printed properly but... (3 Replies)
Discussion started by: bobbygsk
3 Replies

8. Shell Programming and Scripting

Replace Double quotes within double quotes in a column with space while loading a CSV file

Hi All, I'm unable to load the data using sql loader where there are double quotes within the double quotes As these are optionally enclosed by double quotes. Sample Data : "221100",138.00,"D","0019/1477","44012075","49938","49938/15043000","Television - 22" Refurbished - Airwave","Supply... (6 Replies)
Discussion started by: mlavanya
6 Replies

9. Shell Programming and Scripting

Extract multiple columns base on double quotes as delimiter

Hi All, I have my data like below "1","abc,db","hac,aron","4","5" Now I need to extract 1,2,4th columns Output should be like "1",abc,db","4" Am trying to use cut command but not able to get the results. Thanks in advance. (4 Replies)
Discussion started by: weknowd
4 Replies

10. Shell Programming and Scripting

Removal of comma within double quotes

Hi All, I am getting .csv file whenever there is a comma present between a field that field get enclosed with double quotes For eg as below abc,123,xxyy,2178 fgh,123,"x,x"yy",2178 ghi,123,"x,xyy",2178 jkl,123,xx"yy,2178 whereas I want my data as per below abc,123,xxyy,2178... (1 Reply)
Discussion started by: H_bansal
1 Replies
rsh(1)							      General Commands Manual							    rsh(1)

NAME
rsh - Executes the specified command at the remote host or logs into a remote host SYNOPSIS
rsh [-dn] [-l user] remote_host [command] [argument...] The remote shell command (rsh) executes command at the remote_host, or, if no command is specified, logs into remote_host. OPTIONS
Turns on socket debugging (using setsockopt()) on the TCP sockets used for communication with the remote host. Specifies that rsh is to log into the remote host as user instead of the local username. If this option is not specified, the local and remote usernames are the same. Specifies that rsh is to ignore input from STDIN. Use this option if you put rsh in the background without redirecting its input away from the terminal. If you do not use this option in this situation, rsh blocks even if no reads are posted by the remote command. DESCRIPTION
The rsh command sends standard input from the local host to the remote command and receives standard output and standard error from the remote command. If you do not specify a command, rsh executes rlogin instead. If you do not specify the -l option, the local username is used at the remote host. If -l user is entered, the specified username is used at the remote host. In either case, the remote host allows access only if at least one of the following conditions is satisfied: The local user ID is not superuser, and the name of the local host is listed as an equivalent host in the remote /etc/hosts.equiv file. If either the local user ID is superuser or the check of /etc/hosts.equiv fails, the remote user's home directory must contain a $HOME/.rhosts file that lists the local host and username. For security reasons, any $HOME/.rhosts file must be owned by either the remote user or the root user, and should have permissions set to 600 (read and write by owner only). In addition to the preceding conditions, rsh also allows access to the remote host if the remote user account does not have a password defined. However, for security reasons, use of a password on all user accounts is recommended. While the remote command is executing, pressing the Interrupt, Terminate, or Quit key sequences sends the corresponding signal to the remote process. However, pressing the Stop key sequence stops only the local process. Normally, when the remote command terminates, the local rsh process terminates. To have shell metacharacters interpreted on the remote host, place the metacharacters inside (double quotes). Otherwise, the metacharac- ters are interpreted by the local shell. RESTRICTIONS
The rsh command is confused by output generated by commands in a file on the remote host. In particular, the messages, where are you? and stty: Can't assign requested address can result if output is generated by the startup file. EXAMPLES
In the following examples, the local host host1 is listed in the /etc/hosts.equiv file at the remote host host2. To check the amount of free disk space on the remote host host2, enter: $ rsh host2 df To append a remote file to another file on the remote host, place the >> metacharacters in (double quotes): $ rsh host2 cat test1 ">>" test2 To append a remote file at the remote host to a local file, omit the double quotes: $ rsh host2 cat test2 >> test3 To append a remote file to a local file and use a remote user's permissions at the remote host, use the -l option: $ rsh host2 -l jane cat test4 >> test5 FILES
Specifies remote hosts from which users can execute commands on the local host (provided these users have an account on the local host). Specifies remote users that can use a local user account. SEE ALSO
Commands: rcp(1), rlogin(1), rshd(8), telnet(1) Functions: rexec(3) Files: rhosts(4) rsh(1)
All times are GMT -4. The time now is 09:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy