日期:2014-05-16  浏览次数:20904 次

至急 sed 如何取得第一个回车后的所有
现在有如下
update KHI4.ASOF_INFss set ASOF = current date-150 days,USERID = 'GKDP',TIMESTP = Current Timestamp
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0204N "KHI4.ASOF_INFSS" is an undefined name. SQLSTATE=42704

我只想要
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0204N "KHI4.ASOF_INFSS" is an undefined name. SQLSTATE=42704

是否能通过sed 截取第一个回车后的所有字段。

如果您有别的好的方法也可以。
谢谢了。

------解决方案--------------------
BatchFile code

#! /bin/sh
#
# file: skipline.sh
# auth: mymtom
# date: 2008-02-22
#

DATA=`cat <<EOF
update KHI4.ASOF_INFss set ASOF = current date-150 days,USERID = 'GKDP',TIMESTP = Current Timestamp
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0204N "KHI4.ASOF_INFSS" is an undefined name. SQLSTATE=42704
EOF
`
echo "${DATA}"

echo ""
echo "${DATA}" | awk 'BEGIN {getline} 0==0 {print $0}'

echo ""
echo "${DATA}" | \
awk -v n=$1 'BEGIN { for (i = 0; i < n; i++) {getline;} } \
0==0 { printf("%s\n", $0); }'