Finding/replacing text and redirection help

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Finding/replacing text and redirection help
# 1  
Old 11-21-2010
Finding/replacing text and redirection help

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
What command would rename "sequentialInsert", in
~cs252/Assignments/commandsAsst/project/arrayops.h, to
"orderedInsertion" in ~/UnixCourse/commandsAsst/arrayops.h?



2. Relevant commands, code, scripts, algorithms:
I think I need to use the grep, find, and redirection operators, but I am not sure


3. The attempts at a solution (include all code and scripts):
grep 'sequentialInsert' ~cs252/Assignments/commandsAsst/project/arrayops.h > 'orderedInsertion' ~.UnixCourse/commandsAsst/arrayops.h
Unknown user: .UnixCourse.
> grep 'sequetialInsert' ~cs252/Assignments/commandsAsst/project/arrayops.h > "orderedInsertion' ~UnixCourse/commandsAsst/arrayops.h
Unmatched ".
> grep 'sequentialInsert' ~cs252/Assignments/commandsAsst/project/arrayops.h > 'orderedInsertion' ~/UnixCourse/commandsAsst/arrayops.h
orderedInsertion: File exists.
> ls ~cs252/Assignments/commandsAsst/project/arrayops.h > ~/UnixCourse/commandsAsst/arrayops.h
> grep "sequentialInsert" "orderedInsertion"
>



4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Old Dominion University
Norfolk, VA USA
Steven Zeil, CS 252
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 11-21-2010
If your particular version of the sed utility, e.g. GNU sed, supports in-place editing:
Code:
sed -i  's/sequentialInsert/orderedInsertion/g'  arrayops.h

# 3  
Old 11-21-2010
thanks, but the response that i get is

sed: can't read arrayops.h: No such file or directory
Your command did not create ~lothwen/UnixCourse/commandsAsst/arrayops.h
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding a text in files & replacing it with unique strings

Hallo Everyone. I have to admit I'm shell scripting illiterate . I need to find certain strings in several text files and replace each of the string by unique & corresponding text. I prepared a csv file with 3 columns: <filename>;<old_pattern>;<new_pattern> ... (5 Replies)
Discussion started by: gordom
5 Replies

2. Shell Programming and Scripting

Finding a format in a file and replacing it

Hi, I need help in the following: I have a file in directory with mutiple comma seperated values. One of the value is a date and time format like 2012-04-10 xx:yy:zz I need to find that time format in the file and then replace it with xx:yy+1:zz and then save it as a new file and copy it to a... (3 Replies)
Discussion started by: rabh
3 Replies

3. Shell Programming and Scripting

Finding and replacing whole line using sed

Hi all, assume that i am having the following line in a file called file1. triumph and disaster must be treated same. I want to replace this line with. follow excellence success will chase you. is it possible to do this using sed. if possible kindly post me the... (2 Replies)
Discussion started by: anishkumarv
2 Replies

4. Shell Programming and Scripting

Finding a String and Replacing it with an incremental value

Hi Friends, I have a text file which has about 200,000 records in it. we have a string which repeats in each and every record. So we have to write a script in ksh which finds that string on each line and replaces it with a new string(incremental value) for a set every four records. To be... (12 Replies)
Discussion started by: vpv0002
12 Replies

5. Shell Programming and Scripting

Finding and replacing links

Hi, I would like to do a scripting for finding the links based on the name I have and replace the links with the new name. General find command lists everything for that links ( means all the sub-sirs and all the files), i need only the main link and replace. Can you anyone give me some... (1 Reply)
Discussion started by: rrb2009
1 Replies

6. UNIX for Dummies Questions & Answers

Finding & Replacing specific Fields

All I have a very large file (aproximately 150,000) as shown below separated by pipe "|". I need to replace data in 2, 16, 17, 23 fields that are of time stamp format. My goal is to look in those fields and it ends with "000000|" then replace it with "000|". In other words, make it as 6 digit... (2 Replies)
Discussion started by: ddraj2015
2 Replies

7. Shell Programming and Scripting

Need help in finding and replacing port numbers.

Hi All, I am trying to write a shell script which firstly will search some files and then increase the port numbers mentioned in them by a certain no. let me clear it with an example- suppose there r few files a,b,c,d.... file a's content- <serverEntries xmi:id="ServerEntry_1"... (3 Replies)
Discussion started by: ankushsingh10
3 Replies

8. Shell Programming and Scripting

Writing script for finding a string and replacing

Hi all i need some help in writing a small script that searches a string and then replaces it by a new string for searching the best result i get is from find comand combined with xargs e.g. find . -name "*.*" |xargs grep -l "search string" this command I use in root directory and this... (4 Replies)
Discussion started by: Aditya_IT
4 Replies

9. Shell Programming and Scripting

help with finding & replacing pattern in a file

Hi everyone. Could u be so kind and help me with on "simple" shell script? 1. i need to search a file line by line for a pattern. example of a lines in that file 2947 domain = feD,id = 00 0A 02 48 17 1E 1D 39 DE 00 0E 00,Name Values:snNo = f10 Add AttFlag = 0 2. i need to find... (0 Replies)
Discussion started by: dusoo
0 Replies

10. UNIX for Dummies Questions & Answers

shellscript for finding and replacing in DG-UNIX

Newby here..... Is there any way of doing a find & replace within a huge file other than using something like : " vi - FileForReplacing < /u1/excel/consultants " contents of consultants file looks like :1,$s/0000031/CON/g :1,$s/0001032/JONES/g :1,$s/0001355/SMITH/g... (3 Replies)
Discussion started by: Gerry405
3 Replies
Login or Register to Ask a Question