我在这里已经一个任务来提取其具有约1000行日志文件的文件名,日志中的每一行开头的文件名,然后其他的细节,我现在要从每行中提取每个文件名(绝对路径,从'./'开始),并将其放入一个文件中。示例日志文件具有以下数据。shell脚本切片线,并获得第一部分
./plugins-src/rabbitmq-management/src/rabbit_mgmt_wm_overview.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-management/src/rabbit_mgmt_old_db.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-management/src/rabbit_mgmt_wm_exchange.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-management/src/rabbit_mgmt_wm_channel.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-management/src/rabbit_mgmt_wm_vhosts.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-management/src/rabbit_mgmt_wm_permission.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-management/src/rabbit_mgmt_util.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-management/src/rabbit_mgmt_wm_queue_purge.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-management/src/rabbit_mgmt_format.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-management/src/rabbit_mgmt_wm_exchanges.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-management/src/rabbit_mgmt_wm_bindings.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-management/src/rabbit_mgmt_wm_definitions.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-management/src/rabbit_mgmt_wm_queue_get.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-federation-management/src/rabbit_federation_mgmt.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-mqtt/src/rabbit_mqtt_processor.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-mqtt/src/rabbit_mqtt_util.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-mqtt/src/rabbit_mqtt_collector.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-mqtt/src/rabbit_mqtt_frame.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-mqtt/src/rabbit_mqtt_sup.erl:1:%% The contents of this file are subject to the Mozilla Public License
./plugins-src/rabbitmq-mqtt/src/rabbit_mqtt.erl:1:%% The contents of this file are subject to the Mozilla Public License
有一个冒号(:)它可以被用作每行恰好结尾的文件名的分隔符,但我没有专业知识的shell脚本切片,并提取文件名。
这是这么简单! ...谢谢你...... :)它拯救了我的一天。 –
很高兴听到,如果有帮助,请接受答案。 –