cfajohnson your script works great. Now i understand that I was just passing literals rather than variables. I just have two questions about the rest of the script:
(1) what does 'shift' do?
Quote:
(2) how come $@ as opposed to $3?
Because you wanted to operate on more than one file. "$3" is a single argument; "$@" is all the arguments.
This User Gave Thanks to cfajohnson For This Post:
I just created a file in vi, looks like this:
Hello nobody
nobody
What I need is to have sed change the file so it looks like this:
Hello everybody
In other words, the sed query needs to look for both instances of "nobody" before it puts the word "everybody" on the first line. ... (2 Replies)
Dear Experts,
I am new to unix shell programming. I need to write a script which needs to edit 4 text files.
File 1:- PCH_Test.txt
File 2:- PCT_Test.txt
File 3:- PCY_Test.txt
File 4:- PCW_Test.txt
PCH_Test.txt
First it needs to get into PCH_Test file and prefix the 6th coloumn... (2 Replies)
Hi,
I have the following text which I want to search and replace using perl and sed. I would appreciate any help.
Please notice the file contains schema name with a single dot and a double dot . &&WEBDIR_SCHEMA. and &&WEBDIR_SCHEMA .. }
I would like to change it to the acutal schema... (5 Replies)
Hi guys,
say I have a few files in a directory (58 text files or somthing)
each one contains mulitple strings that I wish to replace with other strings
so in these 58 files I'm looking for say the following strings:
JAM (replace with BUTTER)
BREAD (replace with CRACKER)
SCOOP (replace... (19 Replies)
Hi All,
I am fairly new to the world of Unix, and I am looking for a way to replace a line of text in a file with a delimited array of values.
I have an aliases file that is currently in use on our mail server that we are migrating off of. Until the migration is complete, the server must stay... (8 Replies)
HI guys,
Could you help me writing a simple version control script for a text files.
the format could be
./version_control <file(s)> (I want it to be able to work with more than 1 file at the same time)
commands are add and get, add means you add new file(s) to the archive, get means you... (4 Replies)
Hello, I have a comma seperated data sheet with multiple fields of biological data. One column contains the ID name of the sample, where there could be more than one sample separated by a comma. I would like a script that reads this field, and for each sample ID, copies the entire line and writes... (18 Replies)
I need to cat two files with similar names. I am using the following script:
#!/bin/bash
if ]
then
file=$1
file2="${file%R1.fastq}R2.fastq"
echo fetching data from R2 file ...
sleep 3
cat $file $file2 > infile
else
echo "Input_file passed... (2 Replies)
Re: Query on using command "SED" for replacing text in bash shell
While using the command "sed" for find and replace, I wanted to know how one could find a constant and replace it with a variable inside the quotation syntax of sed?
I wanted to replace constant 3 with variable name... (3 Replies)