Skip to content
Advertisement

Tag: grep

Linux/Shell slicing a large text file

Given File1 File2 I wish to make a method that basically does this So given a uniquename from file1 it will use its key from file2 to get what it’s link to. If it doesn’t find uniquename do nothing. MY ATTEMPT Answer The cut utility was designed for this type of data:

What is the point of “grep -q”

I was reading the grep man page and came across the -q option, which tells grep to “not write anything to standard output. Exit immediately with zero status if any match is found, even if an error was detected.” I don’t understand why this could be desirable or useful behavior. In a program who’s reason d’etre seems to be read

How To Replace Strings With X to Y Characters

I have data similar to the following: I am looking for a way to replace strings in field 2. If the number does not have 10-11 characters, I would like to replace it with 12223334444 so the output would be: My original thought was to use cut to get the second field and then use grep “[1-9]” or something similar

need help on shell script for expected output

I have an input file called input.txt like this: I extract the text up to just before the fist capital letter in the first field and store those snippets in output.txt: I used the sed command to separate out the values and it’s working fine. From the output file (output.txt), I need to grep from the first field, and output

Printing awk output in same line after grep

I have a very crude script getinfo.sh that gets me information from all files with name FILENAME1 and FILENAME2 in all subfolders and the path of the subfolder. The awk result should only pick the nth line from FILENAME2 if the script is called with “getinfo.sh n”. I want all the info printed in one line! The problem is that

Live Linux grep script – only print positive results

I try to code a bash 4 (or sh, if that’s possible) script that does the following: 1st parameter: the path to the compressed modules to search, could be “.” 2nd the search pattern to look for The script so far looks like this (be aware that it is not foolproof, it not checks if both parameters are valid, it

Get a particular string from text file

I need to get a particular string from a text file. the content of my file is below : The command that i am trying is : Using this command, I am able to get that particular line in which my string is present. Here is the result of the awk command : What I want to grep is only

How to hide “idle” (both CPU and RAM) processes in top?

I have a linux command based on top that outputs my current tasks snapshot (I’ve assembled it from various SE topics so it may not be optimal but it works for me): The output is something like this: [2018-11-20 18:09:11] {CPU:0.0,MEM:0.2,CMD:uwsgi} [2018-11-20 18:09:11] {CPU:0.0,MEM:0.0,CMD:uwsgi} [2018-11-20 18:09:11] {CPU:0.0,MEM:0.0,CMD:nginx} [2018-11-20 18:09:11] {CPU:0.0,MEM:0.0,CMD:nginx} [2018-11-20 18:09:11] {CPU:0.0,MEM:0.0,CMD:nginx} Actually, I get like 300 lines for

How to use sed/awk/grep [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 4 years ago. Improve this question I have a text given below… Here i dont want string 0.00… from

Advertisement