Write a small shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Write a small shell script
# 1  
Old 10-12-2010
Debian Write a small shell script

Hello Forum members,

Have a nice day.

I have to write a script for the following below scenario.

There are 3 applications located in home directory(ie xyz/app) which have multiple directories and files of diff format(.sh,log,other formats).

Case 1: I have to find the hardcoded IP_ADD 's which are loacted in these three applicatins and assign with respective domain names and redirect into a text file which will save in the xyz/app path.

Case 2:get an IP_ADD from the text file and check in all three applications and repalce with domain name.

Please suggest me a how to write a script for the above scenario.Its urgent ,I am looking forward from you.Smilie


Thanks in Advance,
rajkuma_g

Hello Forum members,

Have a nice day.

I have to write a script for the following below scenario.

There are 3 applications located in home directory(ie xyz/app) which have multiple directories and files of diff format(.sh,log,other formats).
1: I have to find the hardcoded IP_ADD 's which are loacted in these three applicatins and assign with respective domain names

I am searching with the following comand for hardcoded IP_add
Code:
find . -type f  -exec grep -l "[0-p].[0-9].[0-9].[0-9]" {} \;

but it have display the only files which present in the below directories.
Code:
/xyz/gcs/ccc
/xyz/gcs/ddd
/xyz/gcs/eee

but it displaying all the files.so how to write a script for this.
Already I have posted in the shell programming blog but no response its urgent to me please help me,I am looking forward from you.


Thanks in Advance,
rajkuma_g

Last edited by DukeNuke2; 10-12-2010 at 08:43 AM..
# 2  
Old 10-12-2010
Code:
find . -type f ! -name "*.so" -exec grep -l "[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*" {} \;

This User Gave Thanks to ctsgnb For This Post:
# 3  
Old 10-12-2010
If you have files/directories with spaces in their name, the following enhacement might also be usefull (probably only works with GNU coreutils systems):

Code:
find . -type f -print0 | xargs -0 grep -lE '([0-9]{1,3}\.){3}[0-9]{1,3}'

# 4  
Old 10-13-2010
Debian Write a script for multiple occurence of a string

Hello friends,


I have to write a script for find a two strings in different file formats under current directory.

string=hsots and dir=/abc/cia/fsd
please help to wirte a small script for above query.Iam looking forward from you.Smilie


Thanks in advance
Siva Ranganath Ch.
# 5  
Old 10-13-2010
Can you explain what you have so far, and what you're having trouble with?
# 6  
Old 10-13-2010
I am trying to write a script which hadles the following issue
there is IP_ADD is hardcode in some files which are present in 3 different applications those are mentioned below.
for example:
/abc/fds/ghf
/abc/fds/fgd
/abc/fds/kjl
after finding the IP_ADD from this I have to write into a text file and later i will intialize with domain names from command prompt.
please help me to write a script.
1: how to find IP_add from the files present in the below 3 applications
2:after finding how to write into a text file ie redirect
3:how to intialize doman names from command prompt to that IP_add which written in text file.
# 7  
Old 10-13-2010
Quote:
Originally Posted by rajkumar_g
I am trying to write a script which hadles the following issue
there is IP_ADD is hardcode in some files which are present in 3 different applications those are mentioned below.
for example:
/abc/fds/ghf
/abc/fds/fgd
/abc/fds/kjl
after finding the IP_ADD from this I have to write into a text file and later i will intialize with domain names from command prompt.
please help me to write a script.
1: how to find IP_add from the files present in the below 3 applications
2:after finding how to write into a text file ie redirect
3:how to intialize doman names from command prompt to that IP_add which written in text file.
For the 1st and 2nd item maybe this works:

Code:
find . -type f | xargs grep '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'| sed 's#.* \([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*#\1#'

gives the names of the files which includes any IP address (if you only look for a specific IP then you should give it there).

Last edited by EAGL€; 10-13-2010 at 10:36 AM.. Reason: modified the code
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

2. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

3. UNIX for Dummies Questions & Answers

help needed with a small shell script!

I have a scenario where i need to look for files of these kind filename.log.0 filename.log.1 if the files are present, then no action is to be taken, if not found, then it shud create/touch files with the same name. so can anyone help constructing the script for me..appreciate ur help. ... (5 Replies)
Discussion started by: win4luv
5 Replies

4. UNIX and Linux Applications

Need small help to write the code in unix

Hi all, I get data-files which has a particular identified on the 1st record( header ), based on which I've to load a constant for the 1st column of every row. How do I set in the control file using unix shell script. Appreciate if someone can give me some directions on this. Thanks in... (3 Replies)
Discussion started by: lkeswar
3 Replies

5. Shell Programming and Scripting

Need to Write Shell Script based off of this shell command

I'm trying to read a bunch of log files and output the lines that contain particular strings. To accomplish this, I've been running the following from the command line: find . -name "*" | xargs grep " " | grep " " > output.txt Two grep statements are needed in case I'm looking for a... (3 Replies)
Discussion started by: Rally_Point
3 Replies

6. Shell Programming and Scripting

Please help to debug a small shell script (maybe AWK problem)?

Hi Buddies, The following is shell scripts which was borrowed from linux box for load average check. it runs good. (this structure is simple, when load average is too high, it will send alert to user) #!/usr/bin/ksh # Set threshold for 1, 5 and 15 minture load avarage # configured for... (4 Replies)
Discussion started by: GreatJerry
4 Replies

7. Shell Programming and Scripting

Small shell script help required

Hi Guys, Please can some one explain me the below part of code. In this code what is the use of the line in Bold. COPY=0 if ; then echo "$CONF exists and is non-empty - backing it up" SUFFIX=`date +%Y%m%d%H%M%S` echo "cp -p $CONF $CONF.$SUFFIX" cp -p $CONF... (4 Replies)
Discussion started by: max29583
4 Replies

8. Shell Programming and Scripting

Very small Shell Script Help...

The following Script takes each extension and determine what category it belongs and then moves it into a directory based on the extension. (for eg. 1.sh, 5.sh, 9.sh together; 4.csh, 120.csh, 6.csh together and 7.ksh, 2.ksh, 59.ksh together) and moves them to their respective directories viz.... (2 Replies)
Discussion started by: marconi
2 Replies

9. Shell Programming and Scripting

what is problem with this small shell script.. case statement related

Hi All, this small script is written to recognize user input character.. it is in small case .. upeer case or is a number... but when i input first capital letter say A.. it always gives small character.... what is the problem. #!/bin/bash echo "Enter the character" read a case $a in )... (2 Replies)
Discussion started by: johnray31
2 Replies

10. Shell Programming and Scripting

small script - get sql output & write into txt

Hi, how can I write a small script to run the following statement and output the result into check_result.txt select /*+RULE*/ tapname from typetbl where tapname like 'AA%' and rejectcode=9; Normally, I just type sql and get into SQL> (2 Replies)
Discussion started by: happyv
2 Replies
Login or Register to Ask a Question