[20260414]使用nl命令的小问题.txt
--//使用nl缺省值如下:
By default, selects -v1 -i1 -l1 -sTAB -w6 -nrn -hn -bt -fn. CC are two delimiter characters for separating logical
pages, a missing second character implies :. Type \\ for \. STYLE is one of:
a number all lines
t number only nonempty lines
n number no lines
pBRE number only lines that contain a match for the basic regular expression, BRE
FORMAT is one of:
ln left justified, no leading zeros
rn right justified, no leading zeros
rz right justified, leading zeros
--//缺省空行没有编号:
$ nl recordz.txt
1 set verify off
2 variable v_method varchar2(20)
3 exec :v_method := (case when '&2' >= '1' and '&2'<='9999' then 'QQQQ' else '&2' end);
4 define t=&&1;
5 column 4 new_value 4;
6 select decode('&4',null,'loop.txt','&&4') "4" from dual;
7 --@@ &&4 5 &&2 &&3
8 insert into job_times values ( sys_context ('userenv', 'sid') , &3 , dbms_utility.get_time ,:v_method) ;
9 commit ;
10 @@ &&4 &&t &&2 &&3
11 update job_times set time_ela = dbms_utility.get_time - time_ela where sid=sys_context ('userenv', 'sid') and serial# = &3 and method= :v_method;
12 commit;
13 quit
--//可以发现空行没有编号,许多情况下不符合需求,如果需要修改执行如下加入-ba参数如下:
$ nl -ba recordz.txt
1 set verify off
2 variable v_method varchar2(20)
3 exec :v_method := (case when '&2' >= '1' and '&2'<='9999' then 'QQQQ' else '&2' end);
4
5 define t=&&1;
6
7 column 4 new_value 4;
8 select decode('&4',null,'loop.txt','&&4') "4" from dual;
9
10 --@@ &&4 5 &&2 &&3
11
12 insert into job_times values ( sys_context ('userenv', 'sid') , &3 , dbms_utility.get_time ,:v_method) ;
13 commit ;
14
15 @@ &&4 &&t &&2 &&3
16
17 update job_times set time_ela = dbms_utility.get_time - time_ela where sid=sys_context ('userenv', 'sid') and serial# = &3 and method= :v_method;
18 commit;
19 quit
20
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-3116163/ ,如需转载,请注明出处,否则将追究法律责任。