Some bash questions :-)



Hi all,

(1)
The bash command below is meant to firstly list all files with the
specified name; and then print a line containing -2718.

It is proven very useful for me to make sure the contents of a certain
line match up, and if they don't I can easily identify which *input.txt
needs to be corrected. Thanks to the guy who showed me how to use the
find command some time ago...saved me a lot of clicking ;-)

find ./ -name \*input.txt; find ./ -name \*input.txt -exec cat {} \; |
grep -2718

The problem is that the -ve sign causes the following error:
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
find: cat terminated by signal 13

If I put the -2718 as "-2718" it still doesn't work (no terminated
signal, just Usage:...)

What does it mean when cat gets terminated by a signal 13?

How do I get grep to look for negative signs?

(2)
Someone also showed me how to find the current working directory of PID
12345.

It involved: readlink /proc/12345/cwd

How do I pipe it to "cd" so I jump immediately to the directory running
PID 12345?


(3)
Let's say I have several files as below:
/home/me/work/1/input.txt
/home/me/work/2/input.txt
/home/me/work/3/input.txt
and so on

I want to change a line containing:
....
Random seed = 2718
....

To:
Random seed = 314159

in all the files. How do I do this conveniently without resorting to
going to each directory and changing them manually?

(4)
As in (3), but now I want to change a line in 3 consecutive files
containing:
Iterations =

To:
Iterations = 10
Iterations = 100
Iterations = 1000

in each file in each subsequent directory. Can this be done easily?

Thanks in advance.

.



Relevant Pages

  • Re: Some bash questions :-)
    ... The bash command below is meant to firstly list all files with the ... instead of the UUOC (Useless Use Of Cat) and redundant find? ... Try `grep --help' for more information. ... Iterations = 10 ...
    (comp.os.linux.misc)
  • Re: Some bash questions :-)
    ... The bash command below is meant to firstly list all files with the ... Try `grep --help' for more information. ... A double hyphen signales the end of options, ... Iterations = 10 ...
    (comp.os.linux.misc)
  • Re: Some bash questions :-)
    ... The bash command below is meant to firstly list all files with the ... Try `grep --help' for more information. ... A double hyphen signales the end of options, ... Iterations = 10 ...
    (comp.os.linux.misc)
  • group by & count command?
    ... I have a bash command that is essentially grep | sed | sort. ... of sorted records. ... Can this be done via a bash command and if yes, ...
    (RedHat)