URL: https://linuxfr.org/forums/programmation-shell/posts/combine-grep-and-sed-in-one-command Title: combine grep and sed in one command Authors: ahmed-bf Date: 2015年12月07日T10:02:24+01:00 License: CC By-SA Tags: grep et sed Score: -5 I need to get all log done in my project. I'm using this command to do that: ```sh grep -rnw 1ドル -e "Logger.[view]*;$">> log.txt ``` this line return all lines containing **Logger.[one of the these caracters]** contained in the project **directory** "1ドル" except that there are some lines written on **2 or 3 lines (IDE formating)**. In this case I get only the first line only. I want to get the complete text of that log knowing that a log line will always end with " );" example of such line : ```sh Logger.v(xxxxxxxxxxxxx xxxxxxxxxxxxxxxx); ``` Here is my script: ```sh #!/bin/bash echo "Hello Logger! # get project path echo "project directory is 1ドル" # get all project logs and store them into temporary file tmp.txt for processing grep -rnw 1ドル -e "Logger.[view]">> tmp.txt echo "tmp.txt created successfully" # remove package name from previous result and store result into log.txt sed -r 's/.{52}//' tmp.txt>> log.txt echo "log.txt created successfully" grep command return **file_path/file_name : line_number : line**. I found this command that returns only the line even if it is written in 2 or 3 lines but without the **file_path** **file_name** and the **line_number** sed -n '/Logger.[viewd]/{:start /;/!{N;b start};/Logger.[viewd]/p}' Main.java ``` Is there a way to have those two results combined. example : ```sh /home/xxx/xxx/xxx/Main.java:97:Logger.i(xxxxxxxxxxxxx); /home/xxx/xxx/xxx/Main.java:106:Logger.d(yyyyyyyyyyyy yyyyyyyyyyyyyyyyyyyy); ```

AltStyle によって変換されたページ (->オリジナル) /