I am trying to replace a string in multiple lines. It's getting late, and I'm getting restless, maybe someone would rather give him a chance at some DOTS. The line I'm replacing is "STORED AS TEXTFILE" from SQL below ...
PARTITIONED BY(load string, date string, source_file string)
STORED AS TEXTFILE
LOCATION '${staging_directory}/${tablename}';
And so that he looks like ...
PARTITIONED BY(load string, date string, source_file string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE
LOCATION '${staging_directory}/${tablename}';
So my expression
:%s/)\nSTORED AS TEXTFILE\nLOCATION '/)\rROW FORMAT DELIMITED \rFIELDS TERMINATED BY ',' \rSTORED AS TEXTFILE \rLOCATION '/g
What works inside the file (using vim), but I can not get it to work with one command in all files in the directory. I have tried so far ...
sed -i "s/)\nSTORED AS TEXTFILE\nLOCATION '/)\rROW FORMAT DELIMITED \rFIELDS TERMINATED BY ',' \rSTORED AS TEXTFILE \rLOCATION '/g"
... and I also tried the above statement with all spaces. Please, help!
source
share