Sponsored Content
Top Forums Shell Programming and Scripting Search for an undetermined number of spaces Post 303013608 by bedtime on Saturday 24th of February 2018 09:29:43 AM
Old 02-24-2018
Search for an undetermined number of spaces

I would like to find an undetermined number of spaces and shorten them to one space. I am running Debian in mksh. Script running in #!/bin/sh. Sorry to not include all code. The program is too big and involves an online file... too much hassle to solve a simple issue.


Ex.,

I start with (pretend the periods are spaces),

"This . . . . sentence has . . . . . . an undetermined . . number of . spaces between . . . . . . each word."


The result would be:

"This sentence has an undetermined number of spaces."


What I have so far is working but extremely poor code:
Code:
        {gsub (/  /, " ")}
        {gsub (/  /, " ")}
        {gsub (/  /, " ")}
        {gsub (/  /, " ")}
        {gsub (/  /, " ")}
        {gsub (/  /, " ")}
        {gsub (/  /, " ")}
        {gsub (/  /, " ")}

I've tried several combinations to no effect. I've been reading up on awk in a tutorial, but so far no mention of this situation.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search string with invariable spaces

I need to grep for pattern "enable_cal = true".The problem is that different file has different no of spaces in that string. for eg one file will have "enable_cal <space><space><space>=true" next file will have "enable_cal= <space><space>true" other one will have... (5 Replies)
Discussion started by: villain41
5 Replies

2. Shell Programming and Scripting

Split File of Number with spaces

How do i split a variable of numbers with spaces... for example echo "100 100 100 100" > temp.txt as the values can always change in temp.txt, i think it will be feasible to split the numbers in accordance to column. How is it possible to make it into $a $b $c $d? (3 Replies)
Discussion started by: dplate07
3 Replies

3. Shell Programming and Scripting

construct a string with X number of spaces

I'd like to create a variable with the value of X number of space( no Perl please), printf seems to work, but , in following example,10 spaces becomes 1 space when assinged to a variable, Why? other solutions are welcome. $printf "=%10s=\n" = = $var=$(printf "=%10s=\n") echo... (4 Replies)
Discussion started by: honglus
4 Replies

4. UNIX for Dummies Questions & Answers

grep any number of spaces

which one of the following is the correct expression to ignore line with multiple spaces after any string cat file | grep -v "xyz *$" or cat file | grep -v "xyz*$" do i need "*" to specify the sapce or " *" will do? (2 Replies)
Discussion started by: manishma71
2 Replies

5. Shell Programming and Scripting

determine the number of spaces

Here is a weird question :) i am trying to create a script written in bash that will create configuration files for nagios. As some of you aware is has to be written in the below format: define service{ option1 value1 option2 value2... (6 Replies)
Discussion started by: ppolianidis
6 Replies

6. Shell Programming and Scripting

search pattern that has spaces with nawk

Hi guys, I need a help ! I need do grab some string from file and then count n lines after that pattern. This is working fine, but my problem is that the string to be searched has spaces within, like an example : LINK COUNTERS what I am using is: nawk... (2 Replies)
Discussion started by: robdcb
2 Replies

7. Shell Programming and Scripting

Conduct a search or test -f over a path with spaces

I am organizing my music library on a NAS server. I want to print a list of all the directories that are missing the cover art (at least one or more jpeg file). I have successfully created a file with each line containing the path to each occurance of one or more .mp3 files. That path is also... (2 Replies)
Discussion started by: godfreydanials
2 Replies

8. AIX

Search a string having spaces

Hi I am looking to search a string having spaces in a directory for example : my string is "summer hot" my code :for i in `cat position__list.txt` do echo $i" : " `find . -mtime -6 | xargs grep -l ":83D:$i" | xargs ls -ltr|tail -1|awk '{ print $6 , $7 , $8, $9;... (6 Replies)
Discussion started by: wedng.bell
6 Replies

9. Shell Programming and Scripting

Print a specific number of spaces

i'm looking for a command that allows me to print a specific number of spaces which i will provide. something as simple as: spaces=4 printf " " * $spaces i'm looking for somethign that'll allow me to print a specific amount of spaces on a line. can awk be used for this? (4 Replies)
Discussion started by: SkySmart
4 Replies

10. Shell Programming and Scripting

Printing a specific number of spaces

when given a file name, im looking for the most efficient way to turn each letter of the file name into spaces. for instance, the way im thinking of going about this is this: MYFILE=check_disks.sh CHANUM=$(echo ${MYFILE} | awk '{ print length }') printf '%s\n' $CHANUM as you can see... (4 Replies)
Discussion started by: SkySmart
4 Replies
SFDDIFF(1)						      General Commands Manual							SFDDIFF(1)

NAME
sfddiff - compare two font files SYNOPSIS
sfddiff [--help] [--ignorehints] [--ignorenames] [--ignoregpos] [--ignoregsub] [--ignorebitmaps] [--exact] [--warn] [--merge outfile] [--usage] [--version] fontfile1 fontfile2 DESCRIPTION
The program sfddiff compares two font files, which may be in any format fontforge(1) can read. It will notice the following differences: 1) Characters are present in one font but not in the other. 2) Characters are present in both fonts but have different sets of outlines or references. The outlines may be compared so that only exact matches are accepted, or so that a fuzzier match is used. Similarly references may need to match exactly, or may be matched after an unlink. This fuzzy comparison is useful when comparing truetype and postscript fonts, or when comparing a font with references to one with- out. 3) The postscript hints or truetype instructions are different. 4) The font names (the truetype `name' table) differ. 5) The kerning (and other `gpos' information) differs. 6) The ligatures (and other `gsub' information) differ. 7) Any bitmap strikes present in one font but not in the other. 8) Any bitmap characters present in one strike of one font but in the equivalent strike of the other. 9) Any bitmap characters which differ. OPTIONS
--help Provide a description with a list of the available options. --ignorehints Suppress the reporting of hint/instruction differences. --ignoregpos Suppress the reporting of kerning (and other `gpos') differences. --ignoregsub Suppress the reporting of ligature (and other `gsub') differences. --ignorenames Suppress the reporting of name string differences. --ignorebitmaps Suppress the reporting of bitmap differences. --exact Require outlines to match exactly. --warn Warn if the outlines/references are slightly different. --merge outfile Store a merged version of the two fonts into the specified output file. The merged data will be based on sfdfile1, as well as any characters present in sfdfile2 but not in sfdfile1 will be added, and the outlines of sfdfile2 will be placed in the background. Finally, for any characters with different outlines or references the background of the character will contain the outlines from sfdfile2 (references will be unlinked into outlines and those outlines also will be added). --usage Display the usage description. --version Display the current version. SEE ALSO
fontforge(1) The HTML version of the fontforge manual at: http://fontforge.sourceforge.net/ AUTHOR
Copyright (C) 2000-2006 by George Williams (gww@silcom.com). Manual page heavily rewritten and modified to use standard -man(5) macros by R.P.C. Rodgers (rodgers@nlm.nih.gov), 23 October 2002. 8 April 2006 SFDDIFF(1)
All times are GMT -4. The time now is 08:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy