Skip to content
Advertisement

Tag: search

Search string in file via bash but only work match

Find the only string name based on the sub string name in a file. Command used: What works: File content: Output (desired output): What does not work: File content: Output: Need output SomeApi-CURRENT.war Answer It appears, you are interested in the docBase attribute of your xml elements. Specifically those where the value string contains “current” as a substring. But this

searching a file in linux

I want to find in the system a file, and I know part name of it. How could I do that? I tried unsuccessfully the command: The problem is probably very easy however I cannot find a decent tutorial on searching files in linux. Please tell me what command solves my problem and if you know a good tutorial so

grep first n rows, return file name only

I can do the following to search for what I need and return the file name: grep -l “mysearchstring” ./*.xml However the files I am searching are huge so this takes forever. The string I am searching will appear in the first 200 rows so how can I search only the first 200 rows and still return the file name?

Advertisement