我正在尝试使用shell脚本在查询中转换AS
之后的所有单词:
SELECT
first_name AS First_Name,
last_name AS Last_Name,
AGE('1990-10-12') AS Person_Age
FROM table1
我需要的输出是
SELECT
first_name AS first_name,
last_name AS last_name,
AGE('1990-10-12') AS person_age
FROM table1
答案 0 :(得分:3)
如果您使用GNU sed,则可以使用\L
,它是s
command的扩展名,它将其后的所有内容都转换为小写:
$ sed -E 's/(AS)(.*)/\1\L\2/' infile
SELECT
first_name AS first_name,
last_name AS last_name,
AGE('1990-10-12') AS person_age
FROM table1
答案 1 :(得分:1)
使用awk
awk '/AS/ {for (i=1; i<=NF; i++) if ($i == "AS") $(i+1) = tolower($(i+1))} {print}' < infile.sql
答案 2 :(得分:0)
使用Perl
// Load a FeatureCollection from a Fusion Table.
var fromFT = ee.FeatureCollection('ft:1czdOaBYVyu0GA1mcNKIpwEdImsuQqwc0hGudCqv3');
//var selection = fromFT.select('truthCloudCover');
var computePct = function(feature) {
var trPct = ee.Number(feature.get('truthCloudCover')).divide(100.0);
var bin = ee.Number(-99);
if (trPct >= 0.9) {
bin = ee.Number(3);
}
else if (trPct <= 0.1) {
bin = ee.Number(1);
}
else {
bin = ee.Number(2);
}
return feature.set({bin: bin});
};
var fromFT = fromFT.map(computePct);
// show new property values
print('fromFT', fromFT.limit(6));
var foo = fromFT.select('bin');
print('bin', foo);
var getDict = function(feature) {
var foo = feature.get('bin');
};
var binDict = ee.List.add()
var binDict = fromFT.toDictionary(['name']);
print('binDict', binDict);