grep specify file type

本文介绍如何使用grep命令配合正则表达式,高效地搜索包含特定后缀的文件,如.h和.cpp文件,同时提供了排除特定模式的用法。

grep -rI --include \*.h --include \*.cpp pattern path

or

grep -rI --include= \*.{h, cpp} pattern path


exclude patterns: use --exclude


Linking files for Subswath 1 ... Linking files for Subswath 2 ... Linking files for Subswath 3 ... [1] 22215 [2] 22216 [3] 22217 [3] - Done p2p_processing.csh S1_TOPS ... [2] - Done p2p_processing.csh S1_TOPS ... [1] + Done p2p_processing.csh S1_TOPS ... *** buffer overflow detected ***: terminated Aborted (core dumped) *** buffer overflow detected ***: terminated Aborted (core dumped) *** buffer overflow detected ***: terminated Aborted (core dumped) Merging START Number of Files to be merged is 3 merge_swath [ERROR]: Cannot find file ../F1/intf/2025056_2025104/phasefilt.grd merge_swath [ERROR]: Cannot find file ../F1/intf/2025056_2025104/phasefilt.grd merge_swath [ERROR]: File ../F1/intf/2025056_2025104/phasefilt.grd not found [Session merge_swath (0)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16) cannot open grids ../F1/intf/2025056_2025104/phasefilt.grd Number of Files to be merged is 3 merge_swath [ERROR]: Cannot find file ../F1/intf/2025056_2025104/corr.grd merge_swath [ERROR]: Cannot find file ../F1/intf/2025056_2025104/corr.grd merge_swath [ERROR]: File ../F1/intf/2025056_2025104/corr.grd not found [Session merge_swath (0)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16) cannot open grids ../F1/intf/2025056_2025104/corr.grd Number of Files to be merged is 3 merge_swath [ERROR]: Cannot find file ../F1/intf/2025056_2025104/mask.grd merge_swath [ERROR]: Cannot find file ../F1/intf/2025056_2025104/mask.grd merge_swath [ERROR]: File ../F1/intf/2025056_2025104/mask.grd not found [Session merge_swath (0)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16) cannot open grids ../F1/intf/2025056_2025104/mask.grd Merging END Recomputing the projection LUT... grep: S1_20250226_113936_F1.PRM: 没有那个文件或目录 error - could not open file S1_20250226_113936_F1.PRM couldn't open master.PRM Usage: SAT_llt2rat master.PRM prec [-bo[s|d]] < inputfile > outputfile master.PRM - parameter file for master image and points to LED orbit file precise - (0) standard back geocoding, (1) - polynomial refinenent (slower) inputfile - lon, lat, elevation [ASCII] outputfile - range, azimuth, elevation(ref to radius in PRM), lon, lat [ASCII default] -bos or -bod - binary single or double precision output (only output results within data coverage, PRM num_lines, num_rng_bins ) example: SAT_llt2rat master.PRM 0 < topo.llt > topo.ratll error - could not open file S1_20250226_113936_F1.PRM grdinfo [ERROR]: Cannot find file phasefilt.grd grdinfo [ERROR]: Must specify one or more input files Usage: landmask.csh region_cut[0/10600/0/27648] make a landmask in radar coordinates, needs to run with trans.dat NOTE: The region_cut can be specified in batch.config file SNAPHU.CSH - START threshold_snaphu: 0.1 grdmath [ERROR]: corr_patch.grd is not a number, operator or file name grdmath [ERROR]: corr_patch.grd is not a number, operator or file name grdmath [ERROR]: mask2_patch.grd is not a number, operator or file name grd2xyz [ERROR]: Cannot find file phase_patch.grd grd2xyz [ERROR]: Cannot find file phase_patch.grd grd2xyz [ERROR]: File phase_patch.grd not found [Session gmt (0)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16) grd2xyz [ERROR]: Cannot find file corr_tmp.grd grd2xyz [ERROR]: Cannot find file corr_tmp.grd grd2xyz [ERROR]: File corr_tmp.grd not found [Session gmt (0)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16) unwrapping phase with snaphu - higher threshold for faster unwrapping grdinfo [ERROR]: Cannot find file phase_patch.grd grdinfo [ERROR]: Must specify one or more input files snaphu v2.0.4 32 parameters input from file /usr/local/GMTSAR/share/gmtsar/snaphu/config/snaphu.conf.brief (297 lines total) not enough input arguments. type snaphu -h for help grdinfo [ERROR]: Cannot find file phase_patch.grd grdinfo [ERROR]: Must specify one or more input files grdinfo [ERROR]: Cannot find file phase_patch.grd grdinfo [ERROR]: Must specify one or more input files xyz2grd [ERROR]: Must specify -R option xyz2grd [ERROR]: Option -I: Must specify positive increment(s) grdinfo [ERROR]: Cannot find file phase_patch.grd grdinfo [ERROR]: Must specify one or more input files grdinfo [ERROR]: Cannot find file phase_patch.grd grdinfo [ERROR]: Must specify one or more input files xyz2grd [ERROR]: Must specify -R option xyz2grd [ERROR]: Option -I: Must specify positive increment(s) grdmath [ERROR]: tmp.grd is not a number, operator or file name mv: 对 'tmp.grd' 调用 stat 失败: 没有那个文件或目录 grdgradient [ERROR]: Cannot find file unwrap.grd grdinfo [ERROR]: Cannot find file unwrap.grd grdinfo [ERROR]: Must specify one or more input files makecpt [ERROR]: Option T: Must specify valid min[/max[/inc[<unit>|+n]]] option grdimage [ERROR]: Cannot find file unwrap.grd grdimage [ERROR]: Option -I: Must specify intensity file, value, or modifiers psscale [WARNING]: No country code matching unwrap.grd (skipped) psscale [ERROR]: Color palette table unwrap.cpt is empty [Session gmt (0)]: Error returned from GMT API: GMT_CPT_READ_ERROR (8) [Session gmt (0)]: Error returned from GMT API: GMT_CPT_READ_ERROR (8) psconvert [ERROR]: The file unwrap.ps has no BoundingBox in the first 20 lines or last 256 bytes. Use -A option. Unwrapped phase map: unwrap.pdf SNAPHU.CSH - END GEOCODE-START proj_ra2ll.csh grd2xyz [ERROR]: Cannot find file phasefilt.grd grd2xyz [ERROR]: Cannot find file phasefilt.grd grd2xyz [ERROR]: File phasefilt.grd not found [Session gmt (0)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16) gmtinfo [ERROR]: No input data found! surface [ERROR]: Must specify -R option surface [INFORMATION]: Provides 5, expects 3-column binary data surface [ERROR]: Must specify -R option surface [INFORMATION]: Provides 5, expects 3-column binary data grdtrack [ERROR]: Cannot find file raln.grd grdtrack [ERROR]: Cannot find file ralt.grd grdtrack [ERROR]: Must specify -G at least once gmtconvert [WARNING]: File <stdin> is empty! gmtconvert [WARNING]: No data records provided Sampling in geocoordinates with 50 meter pixels ... gmtinfo [ERROR]: No input data found! range: Subscript out of range. gmtmath [ERROR]: Operation "DIV" requires 2 operands gmtmath [ERROR]: Operation "MUL" requires 2 operands gmtinfo [ERROR]: No input data found! blockmedian [ERROR]: Unable to decode as a floating point number blockmedian [ERROR]: Option -I parsing failure. Correct syntax: -I<xinc>[+e|n][/<yinc>[+e|n]] Specify increment(s) and optionally append units or modifiers. For geographic regions in degrees you can optionally append units from this list: (d)egree [Default], (m)inute, (s)econd, m(e)ter, (f)oot, (k)ilometer, (M)ile, (n)autical mile, s(u)rvey foot. +e Adjust the region to fit increments [Adjust increment to fit domain]. +n Increment specifies the number of nodes instead. Then, the actual increments are calculated from the given domain and node- registration settings (see Appendix B for details). Note: If -R<grdfile> was used then -I (and -R and maybe -r) have been set; use -I to override those increments. blockmedian [ERROR]: Must specify -R option blockmedian [ERROR]: Option -I: Must specify positive increment(s) blockmedian [INFORMATION]: Provides 3, expects 3-column binary data xyz2grd [ERROR]: Unable to decode as a floating point number xyz2grd [ERROR]: Option -I parsing failure. Correct syntax: -I<xinc>[+e|n][/<yinc>[+e|n]] Specify increment(s) and optionally append units or modifiers. For geographic regions in degrees you can optionally append units from this list: (d)egree [Default], (m)inute, (s)econd, m(e)ter, (f)oot, (k)ilometer, (M)ile, (n)autical mile, s(u)rvey foot. +e Adjust the region to fit increments [Adjust increment to fit domain]. +n Increment specifies the number of nodes instead. Then, the actual increments are calculated from the given domain and node- registration settings (see Appendix B for details). Note: If -R<grdfile> was used then -I (and -R and maybe -r) have been set; use -I to override those increments. xyz2grd [ERROR]: Must specify -R option xyz2grd [ERROR]: Option -I: Must specify positive increment(s) grdmath [ERROR]: corr.grd is not a number, operator or file name grdmath [ERROR]: phasefilt.grd is not a number, operator or file name proj_ra2ll.csh grd2xyz [ERROR]: Cannot find file phasefilt_mask.grd grd2xyz [ERROR]: Cannot find file phasefilt_mask.grd grd2xyz [ERROR]: File phasefilt_mask.grd not found [Session gmt (0)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16) gmtinfo [ERROR]: No input data found! surface [ERROR]: Must specify -R option surface [INFORMATION]: Provides 5, expects 3-column binary data surface [ERROR]: Must specify -R option surface [INFORMATION]: Provides 5, expects 3-column binary data grdtrack [ERROR]: Cannot find file raln.grd grdtrack [ERROR]: Cannot find file ralt.grd grdtrack [ERROR]: Must specify -G at least once gmtconvert [WARNING]: File <stdin> is empty! gmtconvert [WARNING]: No data records provided Sampling in geocoordinates with 50 meter pixels ... gmtinfo [ERROR]: No input data found! range: Subscript out of range. gmtmath [ERROR]: Operation "DIV" requires 2 operands gmtmath [ERROR]: Operation "MUL" requires 2 operands gmtinfo [ERROR]: No input data found! blockmedian [ERROR]: Unable to decode as a floating point number blockmedian [ERROR]: Option -I parsing failure. Correct syntax: -I<xinc>[+e|n][/<yinc>[+e|n]] Specify increment(s) and optionally append units or modifiers. For geographic regions in degrees you can optionally append units from this list: (d)egree [Default], (m)inute, (s)econd, m(e)ter, (f)oot, (k)ilometer, (M)ile, (n)autical mile, s(u)rvey foot. +e Adjust the region to fit increments [Adjust increment to fit domain]. +n Increment specifies the number of nodes instead. Then, the actual increments are calculated from the given domain and node- registration settings (see Appendix B for details). Note: If -R<grdfile> was used then -I (and -R and maybe -r) have been set; use -I to override those increments. blockmedian [ERROR]: Must specify -R option blockmedian [ERROR]: Option -I: Must specify positive increment(s) blockmedian [INFORMATION]: Provides 3, expects 3-column binary data xyz2grd [ERROR]: Unable to decode as a floating point number xyz2grd [ERROR]: Option -I parsing failure. Correct syntax: -I<xinc>[+e|n][/<yinc>[+e|n]] Specify increment(s) and optionally append units or modifiers. For geographic regions in degrees you can optionally append units from this list: (d)egree [Default], (m)inute, (s)econd, m(e)ter, (f)oot, (k)ilometer, (M)ile, (n)autical mile, s(u)rvey foot. +e Adjust the region to fit increments [Adjust increment to fit domain]. +n Increment specifies the number of nodes instead. Then, the actual increments are calculated from the given domain and node- registration settings (see Appendix B for details). Note: If -R<grdfile> was used then -I (and -R and maybe -r) have been set; use -I to override those increments. xyz2grd [ERROR]: Must specify -R option xyz2grd [ERROR]: Option -I: Must specify positive increment(s) proj_ra2ll.csh grd2xyz [ERROR]: Cannot find file corr.grd grd2xyz [ERROR]: Cannot find file corr.grd grd2xyz [ERROR]: File corr.grd not found [Session gmt (0)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16) gmtinfo [ERROR]: No input data found! surface [ERROR]: Must specify -R option surface [INFORMATION]: Provides 5, expects 3-column binary data surface [ERROR]: Must specify -R option surface [INFORMATION]: Provides 5, expects 3-column binary data grdtrack [ERROR]: Cannot find file raln.grd grdtrack [ERROR]: Cannot find file ralt.grd grdtrack [ERROR]: Must specify -G at least once gmtconvert [WARNING]: File <stdin> is empty! gmtconvert [WARNING]: No data records provided Sampling in geocoordinates with 50 meter pixels ... gmtinfo [ERROR]: No input data found! range: Subscript out of range. gmtmath [ERROR]: Operation "DIV" requires 2 operands gmtmath [ERROR]: Operation "MUL" requires 2 operands gmtinfo [ERROR]: No input data found! blockmedian [ERROR]: Unable to decode as a floating point number blockmedian [ERROR]: Option -I parsing failure. Correct syntax: -I<xinc>[+e|n][/<yinc>[+e|n]] Specify increment(s) and optionally append units or modifiers. For geographic regions in degrees you can optionally append units from this list: (d)egree [Default], (m)inute, (s)econd, m(e)ter, (f)oot, (k)ilometer, (M)ile, (n)autical mile, s(u)rvey foot. +e Adjust the region to fit increments [Adjust increment to fit domain]. +n Increment specifies the number of nodes instead. Then, the actual increments are calculated from the given domain and node- registration settings (see Appendix B for details). Note: If -R<grdfile> was used then -I (and -R and maybe -r) have been set; use -I to override those increments. blockmedian [ERROR]: Must specify -R option blockmedian [ERROR]: Option -I: Must specify positive increment(s) blockmedian [INFORMATION]: Provides 3, expects 3-column binary data xyz2grd [ERROR]: Unable to decode as a floating point number xyz2grd [ERROR]: Option -I parsing failure. Correct syntax: -I<xinc>[+e|n][/<yinc>[+e|n]] Specify increment(s) and optionally append units or modifiers. For geographic regions in degrees you can optionally append units from this list: (d)egree [Default], (m)inute, (s)econd, m(e)ter, (f)oot, (k)ilometer, (M)ile, (n)autical mile, s(u)rvey foot. +e Adjust the region to fit increments [Adjust increment to fit domain]. +n Increment specifies the number of nodes instead. Then, the actual increments are calculated from the given domain and node- registration settings (see Appendix B for details). Note: If -R<grdfile> was used then -I (and -R and maybe -r) have been set; use -I to override those increments. xyz2grd [ERROR]: Must specify -R option xyz2grd [ERROR]: Option -I: Must specify positive increment(s) grdinfo [ERROR]: Cannot find file corr.grd grdinfo [ERROR]: Must specify one or more input files makecpt [ERROR]: Option T: Must specify valid min/max/inc[<unit>|+n] option grdinfo [ERROR]: Cannot find file phasefilt_ll.grd grdinfo [ERROR]: Must specify one or more input files gmtmath [ERROR]: Operation "INV" requires 1 operands grdimage [ERROR]: Cannot find file phasefilt_ll.grd Make phasefilt_ll.kml and phasefilt_ll.png psconvert [ERROR]: Option -E: No argument provided rm: No match. grdinfo [ERROR]: Cannot find file phasefilt_mask_ll.grd grdinfo [ERROR]: Must specify one or more input files gmtmath [ERROR]: Operation "INV" requires 1 operands grdimage [ERROR]: Cannot find file phasefilt_mask_ll.grd Make phasefilt_mask_ll.kml and phasefilt_mask_ll.png psconvert [ERROR]: Option -E: No argument provided rm: No match. grdinfo [ERROR]: Cannot find file corr_ll.grd grdinfo [ERROR]: Must specify one or more input files gmtmath [ERROR]: Operation "INV" requires 1 operands grdimage [ERROR]: Cannot find file corr_ll.grd Make corr_ll.kml and corr_ll.png psconvert [ERROR]: Option -E: No argument provided rm: No match. GEOCODE END rm: No match. DInSAR processing completed successfully.
05-14
#!/bin/bash set -e ================== 配置参数 ================== OPENFIRE_URL=“https://yfw.szrengjing.com:7443/http-bind/” DOMAIN=“yfw.szrengjing.com” COOKIE_FILE=“cookies.txt” LOG_FILE=“xmpp_test.log” INIT_RID=100000 推荐从环境变量获取凭据 USER=“ � � � � � � � � : − � � � � " � � � � � � � � = " XMPP U ​ SER:−test"PASSWORD="{XMPP_PASS:-test123}” 清理旧文件 rm -f “$COOKIE_FILE” “$LOG_FILE” echo “===== 开始 XMPP 自动化测试 =====” | tee -a “$LOG_FILE” =============== 步骤1: 建立 BOSH 会话 =============== echo -e “\n[步骤1/5] 建立 BOSH 会话…” | tee -a " � � � � � � � " � � � = LOG F ​ ILE"RID=((INIT_RID + 1)) SESSION_RESPONSE=$(curl -k -s -c “$COOKIE_FILE” -X POST “$OPENFIRE_URL” -H “Content-Type: text/xml; charset=utf-8” -d “ ” ) echo “会话响应: $SESSION_RESPONSE” | tee -a “$LOG_FILE” SID=$(echo “$SESSION_RESPONSE” | grep -oP ‘sid=["']"'*’ | cut -d' -f2 | head -1) if [ -z “$SID” ]; then echo “❌ 错误:无法提取 sid” | tee -a “$LOG_FILE” exit 1 fi echo “✅ 获取到 SID: $SID” | tee -a “$LOG_FILE” =============== 步骤2: SASL 认证 =============== echo -e “\n[步骤2/5] 执行 SASL PLAIN 认证…” | tee -a " � � � � � � � " � � � = LOG F ​ ILE"RID=((RID + 1)) 构造 PLAIN 认证字符串并 Base64 编码 AUTH_STR=$(printf ‘\0%s\0%s’ “$USER” " � � � � � � � � " ∣ � � � � 64 − � 0 ) � � � � � � � � � � � � = PASSWORD"∣base64−w0)AUTH R ​ ESPONSE=(curl -k -s -b “$COOKIE_FILE” -X POST “$OPENFIRE_URL” -H “Content-Type: text/xml; charset=utf-8” -d “ $AUTH_STR ”) echo “认证响应: $AUTH_RESPONSE” | tee -a “$LOG_FILE” if ! echo “$AUTH_RESPONSE” | grep -q “<success”; then echo “❌ 认证失败,响应不含 ” | tee -a “$LOG_FILE” exit 1 fi echo “✅ 认证成功” | tee -a “$LOG_FILE” =============== 步骤3: BOSH Stream Restart =============== echo -e “\n[步骤3/5] 重启 BOSH 流 (Stream Restart)…” | tee -a " � � � � � � � " � � � = LOG F ​ ILE"RID=((RID + 1)) RESTART_RESPONSE=$(curl -k -s -b “$COOKIE_FILE” -X POST “$OPENFIRE_URL” -H “Content-Type: text/xml; charset=utf-8” -d “”) echo “重启响应: $RESTART_RESPONSE” | tee -a “$LOG_FILE” =============== 步骤4: 绑定资源 =============== echo -e “\n[步骤4/5] 绑定资源…” | tee -a " � � � � � � � " � � � = LOG F ​ ILE"RID=((RID + 1)) BIND_RESPONSE=$(curl -k -s -b “$COOKIE_FILE” -X POST “$OPENFIRE_URL” -H “Content-Type: text/xml; charset=utf-8” -d “ webclient ”) echo “绑定响应: $BIND_RESPONSE” | tee -a “$LOG_FILE” JID=$(echo “$BIND_RESPONSE” | grep -oP ‘\K<+’) if [ -z “$JID” ]; then echo “❌ 资源绑定失败,未找到 JID” | tee -a “$LOG_FILE” exit 1 fi echo “✅ 资源绑定成功,JID: $JID” | tee -a “$LOG_FILE” =============== 步骤5: 发送测试消息 =============== echo -e “\n[步骤5/5] 发送测试消息…” | tee -a " � � � � � � � " � � � = LOG F ​ ILE"RID=((RID + 1)) MESSAGE_RESPONSE=$(curl -k -s -b “$COOKIE_FILE” -X POST “$OPENFIRE_URL” -H “Content-Type: text/xml; charset=utf-8” -d “ 【自动化测试】你好,这是来自 $JID 的测试消息! ”) echo “消息响应: $MESSAGE_RESPONSE” | tee -a “$LOG_FILE” if echo “$MESSAGE_RESPONSE” | grep -qE “(|<message)”; then echo “✅ 消息发送成功” | tee -a “$LOG_FILE” else echo “❌ 消息发送失败或无确认” | tee -a “$LOG_FILE” fi echo -e “\n===== 测试完成 =====” | tee -a “$LOG_FILE” =============== 步骤1: 建立 BOSH 会话 =============== echo -e “\n[步骤1/5] 建立 BOSH 会话…” | tee -a " � � � � � � � " � � � = LOG F ​ ILE"RID=((INIT_RID + 1)) SESSION_RESPONSE=$(curl -k -s -c “$COOKIE_FILE” -X POST “$OPENFIRE_URL” -H “Content-Type: text/xml; charset=utf-8” -d “ ” ) echo “会话响应: $SESSION_RESPONSE” | tee -a “$LOG_FILE” ✅ 安全提取 sid 的方式(适用于任何 grep 实现) SID=$(echo “ � � � � � � � � � � � � � � � " ∣ � � � − � " � / . ∗ � � � = [ ′ ] ¨ SESSION R ​ ESPONSE"∣sed−n"s/.∗sid=[ ′ ] ¨ ​ '"$['"]./\1/p” | head -n1) if [ -z “$SID” ]; then echo “❌ 错误:无法提取 sid” | tee -a “$LOG_FILE” exit 1 fi echo “✅ 获取到 SID: $SID” | tee -a “$LOG_FILE” 生成一个完整版源文件 来测试 REST API Properties Use the form below to enable or disable the REST API and configure the authentication. REST API The REST API can be secured with a shared secret key defined below or a with HTTP basic authentication. Moreover, for extra security you can specify the list of IP addresses that are allowed to use this service. An empty list means that the service can be accessed from any location. Addresses are delimited by commas. Enabled - REST API requests will be processed. Disabled - REST API requests will be ignored. HTTP basic auth - REST API authentication with Openfire admin account. Secret key auth - REST API authentication over specified secret key. Secret key: Custom authentication filter classname - REST API authentication delegates to a custom filter implemented in some other plugin. Note: changing back and forth from custom authentication filter forces the REST API plugin reloading Filter classname: Allowed IP Addresses: Additional Logging Enabled - Logging Enabled Disabled - Logging disabled You can find here detailed documentation over the Openfire REST API: REST API Documentation (opens in new tab)
最新发布
11-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值