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.:slight_smile:

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

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.

/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

find . -type f ! -name "*.so" -exec grep -l "[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*" {} \;
1 Like

If you have files/directories with spaces in their name, the following enhacement might also be usefull (probably only works with GNU coreutils systems):

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

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.:slight_smile:

Thanks in advance
Siva Ranganath Ch.

Can you explain what you have so far, and what you're having trouble with?

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:

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).

Merged the two threads - seems to me the same... (Bumping is not allowed!!!)

Thanks again,

now with above commands i can find the hardcode IP_ADD in all the directories.now i have to write a condition like this.
iam writing alogorithm:

If [IP_add == found]
copy int ip_add.txt file under the path /abc/gcst
read domain names from command prompt.
assign to respective Ip_add in the ip_add.txt
while[ IP_add == found] in the below paths
[ /abc/gcst/xyz or /amex/gcst/kgh or /amex/gcst/rtc]
replace with domain name from the ip_add.txt file.

please help me to write a script for the above alogorithm.iam looking forward from you.:b:

Thanks & Regards
rajkuma g