In my script, this doesn't work. I can copy-and-paste it, and it works. Enabling debugging shows it is resolving the file name correctly... it isn't an issue with special characters in the filename. It returns an error code of 0, but doesn't actually modify the file. Permissions on the file are 644.
Piping the * through ls accomplishes nothing you couldn't have accomplished without it, except possibly scrambling any filenames with whitespace in them -- backticks split across all whitespace, not newlines.
...or even:
What does the '' do? I don't understand the meaning of the blank expression, but if you say it works...
Above examples are for '*', to catch EVERYTHING. I'm going to wind up with an unknown number of files in /tmp/ called file_sw_list, file2_sw_list, etc. etc.
Quote:
Piping the * through ls accomplishes nothing you couldn't have accomplished without it, except possibly scrambling any filenames with whitespace in them -- backticks split across all whitespace, not newlines.
It would be a pretty freaky coincidence to wind up with filenames matching my pattern with whitespace... they're generated from unquotes variables. It could happen, and I always like to sanity check as much as possible, but that's pretty far down my list of worries.
Quote:
...or even:
Neither work. I get the same result.
Quote:
What does the '' do? I don't understand the meaning of the blank expression, but if you say it works...
Two single quotes, not a double quote. I'm performing the operation on a file, and don't want a "backup". BSD sed is picky about this stuff (OS is OSX).
Quote:
Why are you escaping a space?
Because there's a literal space in the pattern I'm matching?
In any case, it turned out to be a second pattern that matched '^Software\ Update' that was so close to the top I didn't notice just a couple of lines missing :-)
Above examples are for '*', to catch EVERYTHING. I'm going to wind up with an unknown number of files in /tmp/ called file_sw_list, file2_sw_list, etc. etc.
Look closely, my examples use * too. They are not pseudocode, * does actually work in those places. That's why putting it through ls is redundant.
If you're concerned about * matching too many files and using ls instead because of this, plugging too many files into ls does not make them not be too many files either.
Hi,
I wanted to configure new iscsi port on HPUX system, i added the target port address and configured it, once done, went to array side and searched for that host iqn number , but was nt able to find the same, came to host, then when i ran "iscsiutil -pVS" command it gave me below result
... (0 Replies)
Hi all,
I have a script that creates folders depending on what variables i enter when calling the script. This all works as expected but what i want to do is add some additional data into another file so that other scripts are aware of this file.
I've found the following sed command which... (12 Replies)
Hi,
I am trying to replace the value of a variable in a file through another script.
Example:
Filename : abc.txt contents:
a=10
b=20
c=30
Need to change the value of, say, b - Tried using the following:
sed "s/${b}/15/g" abc.txt
Have tried various forms of sed (with single quotes,... (4 Replies)
Hi all,
Hereby wish to have your advise for below:
Main concept is
I intend to get current directory of my script file.
This script file will be copied to /etc/init.d.
A string in this copy will be replaced with current directory value.
Below is original script file:
... (6 Replies)
Hi,
I have a small piece of Makefile script which throw's error on Sun Sparc machine, but works fine with Sun Optron, Linux, AIX machines.
FOO=Naveen
test1:FOO=Dhilip
test1:
@echo FOO is ${FOO}
test2:
@echo Me is ${FOO}
Output on Sun Sparc -
ukhml-v890new-~/test: make test1... (5 Replies)
Ok, so, let's say I have the variable $GMAILID....How can I use it with sed command so to replace a string in a file? e.g.:
sed -i 's/$GMAILID/test@gmail.com/' /home/$USER/Desktop/sendmail (4 Replies)
This i will print the second line of a file
sed -n '2p' test2
The use of a variable is impossible here.
a=1
while ; do
line=`sed -n '$a p' test2`
# do some things here with the line variable
a=`expr $a + 1`
done
But the uotput of sed command is 'p'..... What can i do to use a variable... (2 Replies)
Hello,
Im working on this problem for 3 days now and i just cant get it to work.. I tried with alot of different sed methods but didnt find any solution. Its proberly verry simple but i just started bash scripting for a month or so..
i have a file called: file.nfo and file.txt
the content... (4 Replies)
Greetings!
Basically, I would like to properly handle this with gnu make:
alltools: my_tool mysecond_tool mythird_tool etc_tool
%_tool: dir1/%_tool.vf dir2/%_tool/subdir2/%_tool.ver
<tab>@echo done
%.vf:
<tab>RUN_VF $*
%.ver:
<tab>RUN_VER $*
So, if I were to do something like:... (0 Replies)
I have tried everything I can think of to get sed to change line N of a file to the contents of a variable. I have Googled the Internet, and I find lots of people telling how to use variables with the "Substitute" command, but no one telling how to use variables with the "Change" command.
I... (4 Replies)