Help with shell scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with shell scripting
# 1  
Old 12-12-2012
Help with shell scripting

Hi people,
I am new to shell scripting, My problem is i have the output of a shell command in one file,and an output of another command in another file, what i want is, I want to append the output of the second command at a particular location of the first file recursively.

ExSmilieOUTPUT OF Ist COMMAND)File 1 -->
Code:
-------------------blah blah blah some link(/blah/blah/blah) blah blah -----------blah blah blah some link(/blah/blah/blah) blah blah blah----------blah blah blah some link(/blah/blah/blah) blah blah blah

(OUTPUT OF 2nd COMMAND)File 2---->
Three links one after the other in like below
Code:
Link1
Link2
Link3

I think i made myself clear, Now i want to append the file 2 contents in file one just after the string some link in file 1 correspondingly,

The output should be as shown below---
OUTPUT:
Code:
-------------------blah blah blah some link(The first link of file 2) blah blah -----------blah blah blah some link(The second link of file 2) blah blah blah----------blah blah blah some link(The third link of file 2) blah blah blah

Moderator's Comments:
Mod Comment Code tags please


---------- Post updated at 06:57 PM ---------- Previous update was at 04:48 PM ----------

Guys out there!!!!Please help me out with the problem.....Its very urgent.

Last edited by jim mcnamara; 12-12-2012 at 07:30 AM.. Reason: A minor change
# 2  
Old 12-12-2012
Everyone at the UNIX and Linux Forums gives their best effort to reply to all questions in a timely manner. For this reason, posting questions with subjects like "Urgent!" or "Emergency" and demanding a fast reply are not permitted in the regular forums.

For members who want a higher visibility to their questions, we suggest you post in the Emergency UNIX and Linux Support Forum. This forum is given a higher priority than our regular forums.

Posting a new question in the Emergency UNIX and Linux Support Forum requires forum Bits. We monitor this forum to help people with emergencies, but we do not not guarantee response time or best answers. However, we will treat your post with a higher priority and give our best efforts to help you.

If you have posted a question in the regular forum with a subject "Urgent" "Emergency" or similar idea, we will, more-than-likely, close your thread and post this reply, redirecting you to the proper forum.

Of course, you can always post a descriptive subject text, remove words like "Urgent" etc. (from your subject and post) and post in the regular forums at any time.


Thank you.

The UNIX and Linux Forums
# 3  
Old 12-13-2012
Hi admin

Yep i got it....I can wait.Smilie

---------- Post updated 12-13-12 at 01:24 PM ---------- Previous update was 12-12-12 at 07:13 PM ----------

Hi unix lovers,
I am trying to sort this issue for the past one week and i am not able to do.
I have already explained my problem to you guys.
This is a edited version of the post for being more explanatory.

The problem is I have to write a shell script in which i execute 2 commands,both of them stored in two different files.

The contents of the first file say file1.txt is as below
Code:
------------------------------------------------------------------------ string | emailid | 2012-06-21 05:00:01 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah some more string, blah blah blah ------------------------------------------------------------------------ string | emailid | 2012-06-21 22:27:37 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah some more string, blah blah blah ------------------------------------------------------------------------ string | emailid | 2012-06-21 22:45:06 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah some more string, blah blah blah  ------------------------------------------------------------------------

The contents of file1.txt are in a single line in a file

The contents of the 2nd file say file2.txt is as shown below,
Code:
link1
link2
link3

The contents of file2.txt are line by line.

Now the issue is i need to place the contents of the file2.txt at a specific location of file1.txt and the output should be as shown below say file3.txt
Code:
------------------------------------------------------------------------ string | emailid | 2012-06-21 05:00:01 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah
link1
 some more string, blah blah blah ------------------------------------------------------------------------ string | emailid | 2012-06-21 22:27:37 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah 
link2
some more string, blah blah blah ------------------------------------------------------------------------ string | emailid | 2012-06-21 22:45:06 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah 
link3
some more string, blah blah blah  ------------------------------------------------------------------------


Please help me out in accomplishing this task and i quote that i am a newbeee to unix and shell scripting
I know only the basics of SED,AWK and other basic commands of unix.

Thanks,
kashyap.

---------- Post updated at 04:09 PM ---------- Previous update was at 01:24 PM ----------

Dear admin,
I waited for 24 hrs and i am not able to get a suggestion on my issue,
Please help me out in this regard
# 4  
Old 12-13-2012
# 5  
Old 12-13-2012
Two different, contradictory sample lines (not even files!), so maaaany blahs - I'm afraid this is beyond my comprehension.
Pls post again, using meaningful, consistent samples and indications what comes from where and goes to where.
# 6  
Old 12-14-2012
AVikram_Tanwar12: Thanks for the reply. The solution you gave me just places a filed when a pattern is matched.I have got some three to four lines to be appended at specific locations recursively.

---------- Post updated at 01:48 PM ---------- Previous update was at 01:37 PM ----------

Thanks for the reply,
I will explain you again the problem,

I have a file say file1 that contains the output of a command.
Code:
------------------------------------------------------------------------ string | emailid | 2012-06-21 05:00:01 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah some more string, blah blah blah ------------------------------------------------------------------------ string | emailid | 2012-06-21 22:27:37 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah some more string, blah blah blah ------------------------------------------------------------------------ string | emailid | 2012-06-21 22:45:06 +0530 (Thu, 21 Jun 2012) | 1 line Changed paths: M /blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah some more string, blah blah blah  ------------------------------------------------------------------------

Each of the "/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah" is a path that starts somethng like this /client/////...
The above part is the output of a command which is directed into a file. Its is stored in a single line.
Now i have got another file say file2 which contains the output of another command. The output of the second command is as follows,
Code:
Link1---A URL
Link2---Another URL
Link3---URL.

As u knw the link starts with http://

The problem is i want to append the three links in file1 at a location after this string "/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah" which is a path.
So the output should be as given below,
"/client/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah" Link1
"/client/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah"
Link2
"/client/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah"
Linnk3



Another important thing is i need to carry the contents of file1 as well.
NOTE: The outputs that i obtained are SVN commands.
Thanks,
Kashyap
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

2. Shell Programming and Scripting

help me in Shell Scripting

Hi there please have a look at the code..i want to create Using a named pipe. Run a find in the background starting in the working directory While this is happening wait for input from the user to ask him which file to find. If the user does not enter any data in 10 seconds ask the user again.... (1 Reply)
Discussion started by: kattak1511
1 Replies

3. Shell Programming and Scripting

Shell scripting

Hi, if in a network there are lots of PCs connected with either windows or linux as operating system.Then what will be the shell script for the same and also if the PC has linux in it then we have to find if it is occupied or unoccupied. If the PC has windows in it then we have to find if it is... (6 Replies)
Discussion started by: akansha singh
6 Replies

4. UNIX for Dummies Questions & Answers

Shell Scripting

Hey I have a data in the file named as outputFile.txt. The data is in the format 123456,12345678912345,400,09/09/09,INACTIVE. I want this output without commas ie 12345612345678912345400090909INACTIVE. Please tell me what to do and clear explain all the terms, as I am new to it. (6 Replies)
Discussion started by: sampandey31
6 Replies

5. Web Development

Perl scripting or shell scripting?

i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

6. What is on Your Mind?

Shell Scripting vs Perl scripting

Gents, I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Discussion started by: Pouchie1
2 Replies

7. Android

Android Scripting Environment: Shell Scripting and Android

I just upgraded to Android 2.2 from 2.1. The GPS issue that was troublesome in 2.1 seems to have been fixed. Some of web browsing seems faster, but it could just be my connection is better today ;) Flash works in some browsers but not very good and it is too slow for Flash apps designed for... (0 Replies)
Discussion started by: Neo
0 Replies

8. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

9. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

10. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies
Login or Register to Ask a Question