Skip to content

Tag: shell

Find a line in a list of .gz files

i around 50 .gz files in a particular directory in linux. i need to find a particular line in each file. currently i am doing by zcat each file. Eg: Output: Sep 9 17:12:47 145.247.1.62 cap-s12-custfw-1: NetScreen device_id=cap-s12-custfw-1 [Root]system-information-00542: BGP peer 10.24.224.187 changed to Idle…

Shell script file with multiple commands

I want to make shell script file in windows and linux with multiple commands inside it. E.g run.sh and run.bat with the below commands run.bat or run.sh When I run my run.bat file it only executes first command mvn clean but it do not execute other commands. How to make shell-script file with multiple command…

How to remove files without certain extension?

How to remove all files without the .txt and .exe extensions recursively in the current working directory? I need a one-liner. I tried: Answer Try this. The above command will remove all the files other than the .exe and .txt extension files in the current directory and sub directory recursively.

Sort a find command to respect a custom order in Unix

I have a script that outputs file paths (via find), which I want to sort based on very specific custom logic: 1st sort key: I want the 2nd and, if present, the 3rd –separated field to be sorted using custom ordering based on a list of keys I supply – but excluding a numerical suffix. With the samp…

Linux grep command to find the value of key from json

I have a JSON output that contains a list of objects stored in a variable.(I may not be phrasing that right) Output of a curl command: will post in comment as I am unable to post here I want to grep the value at this position “ad6743fae9c54748b8644564c691ba58” shown in the output, which changes ev…