08-26-2010
That command alone will replace those strings in all files in current directory. This is because there is shell globbing operator "*" as the argument for sed command. Did you try that command on some test files? Is it not working properly?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have many files scattered in all different folders. I want to replace the text within all the files using a single command ( awk, sed...) Is it possible?
example
find all the files in which there is text "memory" and replace it with "branded_memories".
the files can be at the... (2 Replies)
Discussion started by: rudoraj
2 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I will use below command for grep single string ("osuser" is search string)
ex: find . -type f | xarg grep -il osuser
but i have one more string "v$session"
here i want to grep in which file these two strings are present.
any help is appreciated,
Thanks in advance.
Gagan (2 Replies)
Discussion started by: gagan4599
2 Replies
3. Shell Programming and Scripting
Hi,
I am trying to get lines between the last occurrences of two patterns. I have files that have several occurrences of “Standard” and “Visual”. I will like to get the lines between “Standard” and “Visual” but I only want to retain only the last one e.g.
Standard
Some words
Some words
Some... (4 Replies)
Discussion started by: damanidada
4 Replies
4. Shell Programming and Scripting
Hello,
I can extract lines in a file, between two strings but only one time.
If there are multiple occurencies, my command show only one block.
Example, monfichier.txt contains :
debut_sect
texte L1
texte L2
texte L3
texte L4
fin_sect
donnees inutiles 1
donnees inutiles 2
... (8 Replies)
Discussion started by: theclem35
8 Replies
5. Shell Programming and Scripting
I have a list of files all over a file system e.g.
/home/1/foo/bar.x
/www/sites/moose/foo.txtI'm looking for strings in these files and want to replace each occurrence with a replacement string, e.g.
if I find: '#@!^\&@ in any of the files I want to replace it with: 655#@11, etc.
There... (2 Replies)
Discussion started by: spacegoose
2 Replies
6. Shell Programming and Scripting
Hi, every one!
I have a file with multiple strings.
file1
ATQRGNE
ASQGVKFTE
ASSQYRDRGGLET
SPEQGARSDE
ASSRDFTDT
ASSYSGGYE
ASSYTRLWNTGE
ASQGHNTD
PSLGGGNQPQH
SLDRDSYNEQF
I want to grep each string in hundreds of files in the same directory, further, I want to find out the string... (7 Replies)
Discussion started by: xshang
7 Replies
7. Shell Programming and Scripting
Hello all,
I have since given up trying to figure this out and used sed instead, but I am trying to understand awk and was wondering how someone might do this in awk.
I am trying to match on the first field of a specific file with the first field on multiple files, and append the second field... (2 Replies)
Discussion started by: karlmalowned
2 Replies
8. Shell Programming and Scripting
Hi All,
I want to use egrep on multiple files and the results should be output to multiple files. I am using the below code in my shell script(working in Ksh shell). However with this code I am not attaining the desired results.
#!/bin/ksh
(
a="/path/file1"
b="path/file2"
for file in... (4 Replies)
Discussion started by: am24
4 Replies
9. Shell Programming and Scripting
I have 4000 files like
$cat clus_grp_seq10_g.phy
18 1002
anig_OJJ65951_1 ATGGTTTCGCAGCGTGATAGAGAATTGTTTAGGGATGATATTCGCTCGCGAGGAACGAAGCTCAATGCTGCCGAGCGCGAGAGTCTGCTAAGGCCATATCTGCCAGATCCGTCTGACCTTCCACGCAGGCCACTTCAGCGGCGCAAGAAGGTTCCTCG
aver_OOF92921_1 ... (1 Reply)
Discussion started by: sammy777888
1 Replies
10. UNIX for Beginners Questions & Answers
Im having an issue when trying to replace the first column with a new set of values in multiple files. The results from the following code only replaces the files with the last set of values in val.txt. I want to replace all the files with all the values.
for date in {1..31}
do
for val in... (1 Reply)
Discussion started by: ncwxpanther
1 Replies
test(1) General Commands Manual test(1)
NAME
test - condition evaluation command
SYNOPSIS
expr
DESCRIPTION
The command evaluates the expression expr and, if its value is True, returns a zero (true) exit status; otherwise, a nonzero (false) exit
status is returned. also returns a nonzero exit status if there are no arguments. The following primitives are used to construct expr:
True if file exists and is readable.
True if file exists and is writable.
True if file exists and is executable.
True if file exists and is a regular file.
True if file exists and is a directory.
True if file exists and is a character special file.
True if file exists and is a block special file.
True if file exists and is a named pipe (fifo).
True if file exists and its set-user-ID bit is set.
True if file exists and its set-group-ID bit is set.
True if file exists and its sticky bit is set.
True if file exists and has a size greater than zero.
True if file exists and is a symbolic link.
True if the open file whose file descriptor number is
fildes (1 by default) is associated with a terminal device.
True if the length of string
s1 is zero.
True if the length of the string
s1 is non-zero.
True if strings
s1 and s2 are identical.
True if strings
s1 and s2 are not identical.
s1 True if s1 is not the null string.
True if the integers
n1 and n2 are algebraically equal. Any of the comparisons and can be used in place of
These primaries can be combined with the following operators:
Unary negation operator.
Binary AND operator.
Binary OR operator
has higher precedence than
Parentheses for grouping.
Note that all the operators and flags are separate arguments to Note also that parentheses are significant to the shell and therefore must
be escaped. All file test operators return success if the argument is a symbolic link that points to a file of the file type being tested.
is interpreted directly by the shell, and therefore does not exist as a separate executable program.
EXTERNAL INFLUENCES
International Code Set Support
Single byte and multibyte character code sets are supported.
EXAMPLES
Exit if there are not two or three arguments:
Create a new file containing the text string if the file does not already exist:
Wait for myfile to become non-readable:
WARNINGS
When the form of this command is used, the matching must be the final argument, and both must be separate arguments from the arguments they
enclose (white space delimiters required.
Parentheses and other special shell metacharacters intended to be handled by test must be escaped or quoted when invoking from a shell.
Avoid such problems when comparing strings by inserting a non-operator character at the beginning of both operands:
This approach does not work with numeric comparisons or the unary operators because it would affect the operand being checked.
AUTHOR
was developed by the University of California, Berkeley and HP.
SEE ALSO
find(1), sh-posix(1), sh(1).
STANDARDS CONFORMANCE
test(1)