Some bash questions :-)
- From: "composlinuxmisc" <altcomphardware@xxxxxxxxxxx>
- Date: 29 Aug 2006 16:13:25 -0700
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.
.
- Follow-Ups:
- Re: Some bash questions :-)
- From: Chris F.A. Johnson
- Re: Some bash questions :-)
- From: John-Paul Stewart
- Re: Some bash questions :-)
- From: ynotssor
- Re: Some bash questions :-)
- From: CBFalconer
- Re: Some bash questions :-)
- From: Robert Hull
- Re: Some bash questions :-)
- Prev by Date: Re: User command to generate a formatted random number?
- Next by Date: connecting to display & tcp capture?
- Previous by thread: how does linux 2.0.x support vga
- Next by thread: Re: Some bash questions :-)
- Index(es):
Relevant Pages
|