Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1 vote
1 answer
113 views

How is it possible that a command chain ending in `cat` prints nothing, but executing `cat again on the same file prints a line?

I run this command sequence: grep -Fxv "sudo: myname : 1 incorrect password attempt ; TTY=pts/3 ; PWD=/home/myname/workspace ; USER=root ; COMMAND=/usr/bin/pip uninstall ansible" ~/.log-...
Stefanos Anagnostou's user avatar
0 votes
1 answer
60 views

copy from text file to other text file , but not owerwiting first 2 lines [duplicate]

I would like to copy the contents of a text file has another text file but do not crush the first 2 lines of the other file, or copy and add the 2 lines to the new file Exemple: user1.txt: Phill Johne ...
Allan Tori's user avatar
-1 votes
1 answer
81 views

If I execute a task from terminal it works, but within a script it don't...Why? [closed]

Tried every step from terminal, one by one. And they work, but when I execute cat $dj_name | grep -Eo "(https)://[a-zA-Z0-9./?=_%:-]*.mp3*" | sort -u > $dj_name-tracks in a script, the ...
Roberto Gonzalez's user avatar
0 votes
1 answer
38 views

chnaging a specific column in a specific row with for loop

I have a file with following content ### beginning of executable commands ### load the necessary module files module load GCC/11.3.0 OpenMPI/4.1.4 CP2K/9.1 ### your program goes here (a.out is an ...
Chintu 's user avatar
-1 votes
1 answer
100 views

bash script that receives any sequence of nucleotides and print all positions of the T nucleotides

I need to write a bash script that receives any sequence of nucleotides and print all positions of the T nucleotides. I did the following: 'vim nucleotide.sh' inside the script #!/bin/bash $@ cat $@ | ...
Eman's user avatar
  • 29
1 vote
4 answers
2k views

How to search a file in linux containing a particular string and then printing all contents of that file?

Requirement : Searching a file in linux containing a string and then printing all contents of that file. Approach I used: grep -ri "<string_name>" | cut -d : -f1 Using this command I ...
Anshuman Madhav's user avatar
0 votes
2 answers
58 views

grep a word from a list of file as a result of grep before

I have a command to grep a file with fullpath that contain a "TypeId: 0", here is the command grep -rnw /home/username/app/data/store/0/part/.mv -e "TypeId: 0" | awk -F ":&...
Yudha Restu's user avatar
0 votes
1 answer
2k views

How use cat and grep with gsutil and filter with a subdirectory name?

Currently, for getting a string (here: 123456789) into some files in all my buckets I do the following: gsutil cat -h gs://AAAA/** | grep '123456789' > 20221109.txt And I get the name of my path ...
Cass's user avatar
  • 144
0 votes
2 answers
162 views

Gnuplot: assign the resulted grep in log file to a variable

my logfile is as: ******************************************************************** maximum disp: 3.2580e-05, at node: 3, of total: 6 maximum disp: 4.2876e-05, at node: 6, of total: 6 *************...
ben's user avatar
  • 1
0 votes
3 answers
139 views

How to load a multiline setting from a file using bash?

I have a long config file which looks like: <some stuff before our example> 'Realtime' => [ 'foo' => 'bar', 'enabled' => true, 'lorem' => 'ipsum' ], &...
Lajos Arpad's user avatar
  • 75.6k
-1 votes
4 answers
55 views

Renaming variant column

I have a large file with rsIDs in the 2nd field. Some variants are in this format: chr1-97981343:rs55886062-AT Using bash commands, how can I replace these identifiers to just print the rsID (e.g. ...
Svalf's user avatar
  • 109
3 votes
4 answers
303 views

bash - extract specific value from file

I have a file that looks like this: odule(load="imfile" PollingInterval="10") $MaxMessageSize 65536 #RSYSLOG_ForwardFormat template is used to enable millisecond-accuracy $...
HollowDev's user avatar
  • 131
1 vote
1 answer
82 views

How can I grep or cat files which begin with a specific number until another specific number?

I would like to grep or cat only files that begin with a specific number and are in a range until a specific number, e.g.: abc_server.2022-04-09-34.log until abc_server.2022-04-09-50.log How can I ...
Tobitor's user avatar
  • 1,498
3 votes
7 answers
187 views

How to print lines where it matchs specific number in bash?

I have a text file called file.txt like below, 01_ABC_0000 AA 02_CDE_0000 BB 03_EFG_0000 CC 04_ABC_0001 DD 05_CDE_0001 EE 06_EFG_0001 FF where it should separated into two different files, like ...
user avatar
1 vote
1 answer
125 views

how to copy&paste cleanly into grep? [closed]

I have some test output, looking like PASS: tests/test_mutex_rmw PASS: tests/test_mutex_trylock PASS: tests/test_malloc_irreg FAIL: tests/ARMCI_PutS_latency FAIL: tests/ARMCI_AccS_latency PASS: tests/...
Rizzer's user avatar
  • 1,023
-1 votes
2 answers
228 views

How to see several lines under one grep line

I want to see the logs where log level is ERROR and I want to see the stackTrace but when I input like below cat app.log | grep ERROR I can't see the stackTrace Is there a way to see several lines ...
user avatar
1 vote
3 answers
75 views

bash: cat + grep to produce several replicas merging two filles

Using Linux bash command line, I need to merge two filles integrating several copies of the file1 inside the specified part of the file 2. The file 1 looks like: ATOM 1 N SER A 1 -2.390 ...
Hot JAMS's user avatar
  • 193
1 vote
2 answers
118 views

How to get only one part of the string without the end in bash

I want to get only one part of the string new-profile-input, the part that I need is: "new-profile" without the "-input". I tried like this: cat automatization_test.sh | grep -oh &...
Belphegor's user avatar
1 vote
1 answer
849 views

using only 'grep' command to get specific column

This below shows this some lines of csv file, i want to get the results that only get the Population column with only using grep command. id,Association,Population,Variant(s),Gene(s),PubMed 1,non-...
ilya jung's user avatar
0 votes
3 answers
267 views

Test if the input stream not empty without consuming data from it

Consider next snippet. generate_build_specs(){ echo ubuntu gcc9 debug echo macos clang debug echo macos gcc10 release echo macos clang release } generate_build_specs | awk -v IGNORECASE=1 '/...
kyb's user avatar
  • 8,031
1 vote
3 answers
131 views

Replace work in line by combining after grep

I need to replace a word after performing a grep and getting the last line of the result. Here my example file: aaa ts1 ts2 bbb ts3 ts4 aaa ts5 ts6 aaa ts7 NONE What I need is to select all lines ...
Fab's user avatar
  • 1,205
-3 votes
1 answer
86 views

Need help, can't see the mistake [closed]

My job is to follow a pipeline of different commands according to the specifications of a paper. However, there is a command with which chromosome names are to be changed. The command is so ...
Stengah966's user avatar
1 vote
5 answers
791 views

How to use awk to filter a .csv file [duplicate]

I was wondering how can I get the names of the fruits in from this .csv file by using awk or some other cli tool. I used a macro in vim to edit the file, but I would think that there is an easy one ...
Brighton Sikarskie's user avatar
-1 votes
2 answers
636 views

Bash print file contents between two strings

a b s start text more text end even more text end I want to print the content between start and first end that follows the start (start is always unique). I also want to print between which lines the ...
GeoCap's user avatar
  • 515
3 votes
3 answers
123 views

How to grep similiar values one by one under each other?

I Have grep from file output like: 2531 POKRZYWNIAK KRZYSZTOF 244 18/01 2 13:46 23:26 3346 SOROTA DARIUSZ 244 18/01 1 04:05 13:46 Need to get it look like this: 2531 POKRZYWNIAK KRZYSZTOF 244 18/01 2 ...
Andrzej TI's user avatar
1 vote
1 answer
214 views

How do I recursively grep files in multiple folders? I'm unable to pipe the recursive cat output

I have 4 folders, set1, set2, set3, set4). Each folder has 1 file called result.txt. Contents of each of the result files look like this: result is: score=19 i'm able to recursively cat the file ...
ElevenCents's user avatar
0 votes
2 answers
1k views

How can I list only directory names, with no trailing "/"?

by doing the following command in the folder ls -d */ | cut -f1 -d'/' I get entries like: env1 env2 env3 env4 how I can use cat/grep or yq/jq or any other alternative command(s) instead of the ...
sasan's user avatar
  • 67
-1 votes
1 answer
78 views

Linux Internal Process for Cat and Grep [closed]

I'm newbie to linux back round process, for example i have the below linux command, Maybe the question will duplicate here but i couldn't find answer so posting it. cat test.txt | grep hello how ...
parrotjack's user avatar
0 votes
1 answer
891 views

How to use grep with curl for lots of urls and return $url

After a lot of cutting and filtering i got a list of urls, in a text file.. i want to pass these urls to a curl command to curl all the urls in the text file and at the same time, grep the output of ...
cherryblossom's user avatar
1 vote
3 answers
163 views

grep for "fixme" as well as "fix me" and then cat results in single file

I am trying to achieve two things here: grep for fixme as well as fix me. the results of the above grep should be in a single file Count number of fixme (including fix me) for step 1 I tried grep -...
AdityaPawar's user avatar
2 votes
1 answer
113 views

Getting a row from a .anno file only when the value of a column is present in a text file

I'm really newbie with scripting and also with stack, so I'm sorry if my question is silly or misplaced. I have to do a task in Bash. I have a DATA.anno file like this one: ID POP LOCALITY 1 Apu ...
Nuthatch92's user avatar
0 votes
1 answer
261 views

Executing cat|grep|grep using 2 pipes

Title is self-explanatory on what I want to do so here is my current code: #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/wait.h> int main() { ...
Sergio's user avatar
  • 275
-1 votes
2 answers
2k views

Best way to find value of a Bash variable in another file without "source"?

Without using source to load another Bash config/script file, what is the simplest way to find the value of a Bash variable that is defined in a different (temporary) file? I have seen similar ...
Jesse Nickles's user avatar
0 votes
3 answers
1k views

Piping into grep using cat returns error: no such file or directory

I am practicing on bash. When I try this command, I get an error: "grep: where: No such file or directory". cat file2.txt | tr " " "\n" | grep –i where | wc -l Content of file2.txt = 1 2 3 4 where 5 ...
prony's user avatar
  • 75
1 vote
2 answers
1k views

Extract field from /proc/meminfo file

/proc/meminfo file gives the cpu requirements of a machine. The out out of the command is as follows: MemTotal: 2002424 kB MemFree: 1061248 kB MemAvailable: 1562492 kB Buffers: ...
Disha Chiplonker's user avatar
0 votes
1 answer
37 views

Combine 3 files into one

I have 3 files. File1 Red Blue Green File2 Apple LadyBug Fire Red Set1 Lettuce Grass Frog Green Set1 Jean Ocean Sky Blue Set1 File3 BlueBerries Blue Set2 Rose Red Set2 Tree Green Set2 Output ...
user208571's user avatar
0 votes
0 answers
60 views

Partial file lines replace in linux

I have a file containing some lines Example: Line 1 , @A11 @A21 @A31 Line 2 , @A12 @A22 @A32 Line 3 , @A13 @A23 @A33 I have other files which lines might contain some of the lines in the above ...
Lucky me's user avatar
0 votes
1 answer
1k views

Bash Mapfile or Read while grep-ing contents of a file

Just looking for any other, perhaps better ways to do the following. Shell check is calling "SC2002 Useless cat" and every other way I have tried to mitigate has failed. It is working as desired, so ...
Josh Williamson's user avatar
1 vote
2 answers
3k views

How to select date range in awk

We are making a utility to ssh to different servers and collect all the error logs and send to the concerning teams this utility will cat the log file and filter using awk. e.g. cat /app1/apache/...
slimshady's user avatar
1 vote
1 answer
1k views

Loop through files to find a string and send files containing that string to directories of the same name in bash

I have a parent directory with ~500 files with each filename beginning with cert, i.e. cert-104.mol2, cert-105.mol2 and so on. Each of these cert files contains a seven number identifier inside, i.e. ...
Christian Seitz's user avatar
2 votes
1 answer
665 views

Not getting grep result using popen with cat and multiple process pipes

I am trying to get grep to work using pipes and subprocess. I've double-checked the cat and I know it's working, but for some reason the grep isn't returning anything, even though when I run it ...
Ippy's user avatar
  • 21
0 votes
2 answers
483 views

How to show specific word from a specific line?

let say I have a text file and I want to show echo from it only the 3rd word in the 48th line, how can I do it? I was able to show a specific line from the text file: sed -n 48p log.txt but now I ...
Mr_Shxx's user avatar
0 votes
2 answers
35 views

Print specific lines from file

I have a text file like this: OBJ O1 = { {P11}, {0} }; OBJ O2 = { {P21}, {P22}, {P23}, {0} }; OBJ O3 = { {P31}, {P32}, {0} }; I want to print only lines starting by OBJ O2 and ending by first {0} ...
Nesrine_Kh's user avatar
0 votes
2 answers
65 views

Search a value in a file and change a number 3 lines after match

We want to find a specific line in a file and change a value 3 lines after the match. For example we are searching for the string "class_rproxy" cat /var/git/control/Puppetfile | grep -A 3 ...
André Deseive's user avatar
0 votes
3 answers
149 views

Merge multiple files containing same IDs - Linux

i have 10000 files in One folder like this : 1000.htm Page_1000.html file-1000.txt 2000.htm Page_2000.html file-2000.txt i want merge each files that have similar name example : 1000.htm Page_1000....
H.Otmane's user avatar
0 votes
2 answers
381 views

How to use lines in a file as keyword for grep?

I've search lots of questions on here and other sites, and people have suggested things that should fix my problem, but I think there's something wrong with my code that I just don't recognize. I ...
lozzib's user avatar
  • 5
1 vote
2 answers
255 views

Output file much larger than input files after cat + grep

I have 18 csv files, all between 1mb and 14mb. The sum of all files is 64mb. I want to create a new csv file that contains a subset of those files-- only the lines featuring the pattern "Hello" (or "...
Hubert Léveillé Gauvin's user avatar
2 votes
2 answers
3k views

Pipe cat/grep/arguments into variable in bash script

#!/bin/bash DATE=`date +%Y-%m-%d` HOUR=`date +%H` ORDERS_THIS_HOUR=`cat cli.log | grep $DATE $HOUR | grep -o "generated for Production" | wc -l` OUTPUT="$DATE $HOUR : $ORDERS_THIS_HOUR" echo "$OUTPUT"...
pcgben's user avatar
  • 756
1 vote
2 answers
124 views

sequentially replace a word using another text file list of words - data_file

in my head I have: read "original_file", change line 3 "ENTRY1" to be that of the FIRST Word in data_file. write out new_file1. read "original_file", change line 3 "ENTRY1" to be that of the SECOND ...
user avatar
0 votes
3 answers
4k views

Recursive grep for gz files search string from an output string

I'm trying to search a string from an output of a string in recursive search with gz files folder. I'm using the command which is only worked: find . -name "*.gz" -exec zgrep -H 'PATTERN' \{\} \; ...
Ozicek's user avatar
  • 41