-1

I met a makefile as shown below:

GENERAL_RULES   = $(WM_DIR)/rules/General
include $(GENERAL_RULES)/general


#------------------------------------------------------------------------------
# Declare names of make system control files derived from file 'files'
#------------------------------------------------------------------------------

OBJECTS_DIR     = $(MAKE_DIR)/$(WM_OPTIONS)
OPTIONS         = $(OBJECTS_DIR)/options
FILES           = $(OBJECTS_DIR)/files
VARS            = $(OBJECTS_DIR)/variables
SFILES          = $(OBJECTS_DIR)/sourceFiles

-include $(OPTIONS)


#------------------------------------------------------------------------------
# Declare dependency of all make system files on FILES
# Causes all derived files to be remade if any are changed or missing
#------------------------------------------------------------------------------

all : $(OPTIONS) $(SFILES) $(VARS)

$(OPTIONS) : $(MAKE_DIR)/options
    @$(CPP) $(GFLAGS) $(MAKE_DIR)/options | sed -e 's@   *@ @g' > $(OPTIONS)

Can anyone explain the meaning of the last line of code above? There are three @ signs in one single sed command. I didn't quite understand the meaning of the @ sign. Please help.

Beta
  • 96,650
  • 16
  • 149
  • 150
Jerry
  • 323
  • 1
  • 2
  • 10
  • Please identify in your makefile those whitespaces which are tabs and thereby allow to tell them apart from those whitespaces which are merely spaces. – Yunnosch Jul 29 '19 at 20:28
  • 3
    Possible duplicate of [Why does sed command contain at symbols](https://stackoverflow.com/questions/28161275/why-does-sed-command-contain-at-symbols) – Ruud Helderman Jul 29 '19 at 20:32
  • @Yunnosch You mean the whitespaces after the first @ sign is a tab, and the whitespace after the second @ sign is mere space? What does those @ signs mean? – Jerry Jul 29 '19 at 20:33
  • Thanks for clarifying. – Yunnosch Jul 29 '19 at 20:33
  • Could you double check the first whitespace? In my experiments the result is weird if there is only one whitespace. It makes more sense if there are two, e.g. two tabs, or two blanks, or maybe a blank and a tab, or a tab and a blank... – Yunnosch Jul 29 '19 at 20:41

1 Answers1

1

Sed is quite tolerant when it comes to setting up a search and replace, allowing for many characters to serve as delimiter.

The

sed -e 's@   *@ @g'

is probably more easily recognisable as

sed -e 's/   */ /g'

i.e.

  • search and replace
  • the kind of white space seen before the first delimiter, i.e. a tab
  • any number, including 0 (which makes me think that there must be two tabs before the second delimiter, one "always", second "repetition any number")
  • with the whitespace after the second delimiter, i.e. a single blank/space
  • globally
Yunnosch
  • 26,130
  • 9
  • 42
  • 54