Sponsored Content
Top Forums Shell Programming and Scripting Spaces in names between quotes Post 302962451 by Don Cragun on Monday 14th of December 2015 08:54:28 PM
Old 12-14-2015
I'm not clear on what you are trying to do.
The commands:
Code:
echo "services": [ "check_win_semsrv_process", "checking logs", "check_win_semwebsrv_process", "check_win_semlaunchsrv_process" ] "contact groups": [ "HQ-InfoSec-DG", "nag-snowed", ],

and:
Code:
echo services: [ check_win_semsrv_process, checking logs, check_win_semwebsrv_process, check_win_semlaunchsrv_process ] contact groups: [ HQ-InfoSec-DG, nag-snowed, ],

both produce exactly the same output:
Code:
services: [ check_win_semsrv_process, checking logs, check_win_semwebsrv_process, check_win_semlaunchsrv_process ] contact groups: [ HQ-InfoSec-DG, nag-snowed, ],

So why are you wasting time putting double-quotes in an echo command that you know are going to be stripped by the shell before echo sees its arguments? Is this echo command producing output that is an accurate representation of the data that you really want the rest of this pipeline to process?

Aia,
Since the submitter doesn't want the double quotes anyway. A simpler awk script (ignoring the unneeded double-quotes in the original echo command) would be:
Code:
echo "services": [ "check_win_semsrv_process", "checking logs", "check_win_semwebsrv_process", "check_win_semlaunchsrv_process" ] "contact groups": [ "HQ-InfoSec-DG", "nag-snowed", ], |
    awk -F" [][] " '{gsub(/, /,",\n",$2);print $2}'

But, of course, this only works if the character sequence <comma><space> never appears inside a what might have been intended to be a double-quoted string in the field that is being processed by awk.
This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Directory names that contain spaces and other suggestions?

The script below was written to select files and convert a particular string to something other and replace that file. However, I came across some issues with filenames that contain spaces, any suggestions to get around this? Any other suggestions that may apply to this code would also be... (5 Replies)
Discussion started by: Shakey21
5 Replies

2. Shell Programming and Scripting

File names with spaces? Is it possible?

Gurus - I got one simple TXT file with long file name with blank spaces in between the words. I am trying to display that full file name, but it breaks while displaying. Could somebody shed some light here? Script ------ for i in `cat ~\temp\employee.txt` do echo $i done (5 Replies)
Discussion started by: Eric_2005
5 Replies

3. Shell Programming and Scripting

Strong quotes and spaces

We ran into a problem because of a shop that uses Windows and UNIX. The file names that Windows uses have spaces in them. When they get moved to the unix system they still have spaces. This produces a problem in our script that moves them again from one unix system to another. I've made up a... (2 Replies)
Discussion started by: jimcampanella
2 Replies

4. Shell Programming and Scripting

Remove spaces between file names

Hi All, I have spaces in between file names. "Material Header.txt" "Customer Header.txt" "Vendor Header.txt" And how can I remove spaces between file names like below MaterialHeader.txt CustomerHeader.txt VendorHeader.txt Thanks Srimitta (10 Replies)
Discussion started by: srimitta
10 Replies

5. Shell Programming and Scripting

sed replace spaces between quotes with a variable

I have lines with: elseif (req.http.host ~ "^(www.)?edificationtube.com$|www.edificationtube.org www.edificationtube.net edificationtube.org www.edificationtube.com edificationtube.net") { elseif (req.http.host ~ "^(www.)?collegecontender.com$|www.collegecontender.com collegecontenders.com... (3 Replies)
Discussion started by: EXT3FSCK
3 Replies

6. Shell Programming and Scripting

Opening File names with spaces inside it !- PERL

I developed a perl code..And the excerpt from it is given below... open(HANDLE,$cmp_path) ; #reading the xml file from the file path while($file_path = <HANDLE>) I have list of XML files to read from a folder. It has some spaces inside the name of the file...I used "\"... (2 Replies)
Discussion started by: gameboy87
2 Replies

7. Shell Programming and Scripting

How to strip the spaces in file names?

please somebody tell me what is wrong with this, while the thumbnail grabbing works and encoding works, but what is not working is, mv $i.jpg /var/www/thumbs/ and mv $i.mp4 /var/www/uploads/ #!/bin/bash # MINT 9 - FFMPEG - QT-FASTSTART - X264 - MP4 DIR=/var/www/tmp for i in... (9 Replies)
Discussion started by: mysoogal
9 Replies

8. Shell Programming and Scripting

How to replace spaces excluding those within double quotes and after backslash?

In bash or perl, I would like to know how to substitute a null character (0x00) for every white space without changing the white spaces inside the block of double quotes and the white space immediately following a backslash. Suppose that sample.txt consists of the following line. "b 1" c\ 2 ... (2 Replies)
Discussion started by: LessNux
2 Replies

9. Shell Programming and Scripting

Remove spaces from start of file names

Hi, I have a directory with the following file names 01 - abc hyn 02-def 03-ghi.dir 04 - jhu.dir abc1 kil def bil The last two file names abc1 starts with one space and def starts with double space. I want these files in my directory to be renamed as ABC HYN DEF GHI.dir... (6 Replies)
Discussion started by: jacobs.smith
6 Replies

10. Shell Programming and Scripting

Spaces in double quotes in variable ?

Hi got this issue and was wondering if someone could please help out ? var='." "' echo $var ." " I 'll get ." " and not ." with 10 spaces in between " Thanks (3 Replies)
Discussion started by: stinkefisch
3 Replies
All times are GMT -4. The time now is 06:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy