Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
So I am trying to use
grep -v -f A.txt B.txt
to display lines NOT included in file A but present in file B. When I
grep -f A.txt B.txt
everything works fine I receive output with correct lines highlighted, but when I use
grep -v -f A.txt B.txt
nothing is outputted in spite of the fact that not all lines match patterns. Does anyone knows why? I am interested in seeing lines NOT present in file A.
Note: I am including just a sample of original file but it includes all troublesome lines.
file B.txt contents:
/lgi/tch/4337984048.html
/mnh/tch/4337954734.html
/fct/tch/4337745272.html
/brk/tch/4337711890.html
/mnh/tch/4337530587.html
/mnh/tch/4337480118.html
/mnh/tch/4337393833.html
/wch/tch/4337280071.html
/wch/tch/4337105236.html
/brk/tch/4337068170.html
file A.txt contents:
/mnh/tch/4337480118.html
/mnh/tch/4337393833.html
/wch/tch/4337280071.html
/wch/tch/4337105236.html
/brk/tch/4337068170.html
Related
Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 months ago.
Improve this question
When I type echo Hello$'\n'world | cat -n I get the output as expected:
1 Hello
2 world
But if I want to number line of g++ -v | cat -n I get an unnumbered result.
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
...
What's wrong with my command?
The output of g++ -v goes to the standard error, not standard output. Redirect stderr to stdout to process it in a pipeline:
g++ -v 2>&1 | cat -n
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
Running a grep command on my file gives me the following output:
15-5-65
52-5-93
51-4-82
21-0-86
54-6-09
63-2-68
26-7-85
24-9-46
16-7-59
81-5-42
31-7-63
54-0-84
69-8-80
74-1-27
19-9-86
41-8-74
13-2-03
21-3-61
56-7-60
81-9-47
I want to use each of these as a partial input to another grep command, such as grep '02729-AS-27' maps/projects.dat | grep '...-...' circuit_(pipe input).dat How do I properly format this command?
If this isn't clear, the files I want to search are called for example circuit_81-5-42.dat with numbers corresponding to the output of the first grep command above.
I hope this is what you want:
while IFS= read -r line; do
grep "...-..." "circuit_${line}.dat"
done < <(grep "02729-AS-27" "maps/projects.dat")
Or:
grep "02729-AS-27" "maps/projects.dat" | xargs -i grep "...-..." "circuit_""{}"".dat"
Please replace the pattern ...-... with the appropriate one.
Hope this helps.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Trying to find a string in *.gz file and try the following;
zipgrep user >filename>.gz
[<filename>.gz]
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
zipinfo: cannot find zipfile directory in one of <filename>.gz or
010414:22:59.serverlog.gz.zip, and cannot find <filename>.gz.ZIP, period.
/usr/bin/zipgrep: test: argument expected
zgrep is not available;
zgrep -h
-bash: zgrep: command not found
Thanks for your help.
I tried zcat also but it is giving me this error; .gz |grep -i user-user
That indicates you're doing something like this:
zcat '<filename>.gz |grep -i user-user <filename.serverlog.gz.Z'
You want this:
zcat filename.gz | grep -i user-user
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
How could I get the list of files and size in a specific directory and store the result in a text file.
For example:
For directory /some/directory I would like a file listing all the files contained in that directory like this:
fileA sizeofA dateA
fileB sizeofB dateB
fileC sizeofC dateC
fileD sizeofD dateD
Test this using stat :
cd /some/directory
stat -c '%n %B %y' *
See
man 1 stat
You can use stat command:
stat -c '%n %s %y' *
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
When I am using the cut command in linux, and redirecting the output to the same file, it seems to delete the contents of my file. What I am doing is:
cut -d " " -f 1 file1.txt > file1.txt
My goal is to cut out all columns from the file, except for the first column and save changes to the file that I am working with. But when I do this, and open my file, I am left with a blank file. However, when I specify a different file, the command seems to work perfectly fine.
When I run:
cut {some command} FILE1.txt > FILE2.txt
This seems to work fine.
Is there a way that I can specify that I want the changes from my cut command to be overwritten on to my current working file?
Create a temporary file with the desired changes and then rename it to the target file name:
cut -d " " -f 1 file1.txt > file1.txt.temp
mv file1.txt.temp file1.txt