Sponsored Content
Top Forums Shell Programming and Scripting Need to update the text file with next version of deployment(V1,V2,V3) Post 303002610 by RudiC on Tuesday 29th of August 2017 05:08:43 AM
Old 08-29-2017
Quote:
Originally Posted by naresh2389
Hi..How to update the next deployment version. in txt file by taking previous version of file(CMD_HG-120-V3 and next deployment version should be CMD_HG-120-V4).
Also once deployment is successful need to update status CMD_HG-120-V4-DEV-SUCCESS.

Code:
CMD_HG-120-V1
CMD_HG-120-V1-DEV-SUCCESS
CMD_HG-120-V2
CMD_HG-120-V2-DEV-SUCCESS
CMD_HG-120-V3

I ma trying below script.
Code:
#!/bin/bash
myfile="/tmp/file/new.txt"
if [[ -e $myfile ]]
then echo "File Exist"
if [ -s /tmp/file/new.txt ]
then oldnum=`cut -d '-' -f3 /tmp/file/new.txt`
echo "Non Empty File"
newnum=`expr $oldnum + 1`
echo $newnum
echo"CMD_HG-120-$newnum" >> /tmp/file/new.txt/new.txt
else
echo "loop"
echo "CMD_HG-120-V1" >> /tmp/file/new.txt
fi
else
echo $myfile
fi


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!



Not clear.
What exactly is your request? Your script doesn't give the expected result? Gives error messages?
What's the contents of the txt file? Where is CMD_HG-120-V4-DEV-SUCCESS going to? Why do you define the myfile variable, but then use string constants for the target file? Why do you append to /tmp/file/new.txt/new.txt?

Last edited by RudiC; 08-29-2017 at 08:34 AM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trying to Parse Version Information from Text File

I have a file name version.properties with the following data: major.version=14 minor.version=234 I'm trying to write a grep expression to only put "14" to stdout. The following is not working. grep "major.version=(+)" version.properties What am I doing wrong? (6 Replies)
Discussion started by: obfunkhouser
6 Replies

2. Red Hat

war file deployment

Hi Experts. I need to install one help library in Fedora 13 and I got the installation document for it: --------------------------------------------------- users need their own J2EE web application server to be able to complete this installation. The server must support J2EE - JSP... (3 Replies)
Discussion started by: orma
3 Replies

3. Shell Programming and Scripting

Update strings in text file

I have a txt file that contains multiple occurrances of: <MoreFlag>Y</MoreFlag> I want to update these to: MorePACFlag>Y</MorePACFlag> How would I do this? Cheers Paul (2 Replies)
Discussion started by: runnerpaul
2 Replies

4. Solaris

Update java version in Zone

I am using a solaris zone in Sun blade-T6320 which has a java version "1.5.0_18" i want to update it to 1.6.0.16 or higher , how can i do that , does i need to add the new java package to the global server or just instal it in the zone itself. do i need to remove the older version or and install... (1 Reply)
Discussion started by: Sojourner
1 Replies

5. UNIX for Dummies Questions & Answers

Auto Version update

We have a version for every file like RHZ 1.0 / Ver 1.4.2 etc. Whenever I place a new file with same file name i want the version to get auto upgraded. So can anyone suggest code.. Eg: RHX 1.0 -> RHZ 1.1 Ver 1.4.2. -> Ver 1.4.3 (1 Reply)
Discussion started by: krishna87
1 Replies

6. Red Hat

Specify version in yum update

Hello All, I am trying to upgrade redhat from 5.6 to 5.8. When i use Code: yum update -y it installs 5.9 I dont want 5.9, instead i would like to upgrade to 5.8 is there anyway to specify a version when you are doing Code: yum update (4 Replies)
Discussion started by: adam25ca
4 Replies

7. Shell Programming and Scripting

Update specific field in a line of text file

I have a text file like this: subject1:LecturerA:10 subject2:LecturerA:40 if I was given string in column 1 and 2 (which are subject 1 and LecturerA) , i need to update 3rd field of that line containing that given string , which is, number 10 need to be updated to 100 ,for example. The... (6 Replies)
Discussion started by: bmtoan
6 Replies

8. UNIX for Beginners Questions & Answers

awk to update file with partial matching line in another file and append text

In the awk below I am trying to cp and paste each matching line in f2 to $3 in f1 if $2 of f1 is in the line in f2 somewhere. There will always be a match (usually more then 1) and my actual data is much larger (several hundreds of lines) in both f1 and f2. When the line in f2 is pasted to $3 in... (4 Replies)
Discussion started by: cmccabe
4 Replies

9. UNIX for Beginners Questions & Answers

How to manipulate a text file and store each version for every changes in a directory?

I attached both picturehttps://1drv.ms/t/s!Aoomvi55MLAQh1jODfUxa-xurns_ and *.txt file of a sample work file. In this file Reactions which only start with "r1f", "r2f", "r3f"......and so on. And for each reaction the reaction rates is situated couple of lines later with a "+" sign. For each... (1 Reply)
Discussion started by: Atta
1 Replies
update-motd(5)							File Formats Manual						    update-motd(5)

NAME
update-motd - dynamic MOTD generation SYNOPSIS
/etc/update-motd.d/* DESCRIPTION
UNIX/Linux system adminstrators often communicate important information to console and remote users by maintaining text in the file /etc/motd, which is displayed by the pam_motd(8) module on interactive shell logins. Traditionally, this file is static text, typically installed by the distribution and only updated on release upgrades, or overwritten by the local administrator with pertinent information. Ubuntu introduced the update-motd framework, by which the motd(5) is dynamically assembled from a collection of scripts at login. Executable scripts in /etc/update-motd.d/* are executed by pam_motd(8) as the root user at each login, and this information is concatenated in /var/run/motd. The order of script execution is determined by the run-parts(8) --lsbsysinit option (basically alphabetical order, with a few caveats). On Ubuntu systems, /etc/motd is typically a symbolic link to /var/run/motd. BEST PRACTICES
MOTD fragments must be scripts in /etc/update-motd.d, must be executable, and must emit information on standard out. Scripts should be named named NN-xxxxxx where NN is a two digit number indicating their position in the MOTD, and xxxxxx is an appropriate name for the script. Scripts must not have filename extensions, per run-parts(8) --lsbsysinit instructions. Packages should add scripts directly into /etc/update-motd.d, rather than symlinks to other scripts, such that administrators can modify or remove these scripts and upgrades will not wipe the local changes. Consider using a simple shell script that simply calls exec on the external utility. Long running operations (such as network calls) or resource intensive scripts should cache output, and only update that output if it is deemed expired. For instance: /etc/update-motd.d/50-news #!/bin/sh out=/var/run/foo script="w3m -dump http://news.google.com/" if [ -f "$out" ]; then # Output exists, print it echo cat "$out" # See if it's expired, and background update lastrun=$(stat -c %Y "$out") || lastrun=0 expiration=$(expr $lastrun + 86400) if [ $(date +%s) -ge $expiration ]; then $script > "$out" & fi else # No cache at all, so update in the background $script > "$out" & fi Scripts should emit a blank line before output, and end with a newline character. For instance: /etc/update-motd/05-lsb-release #!/bin/sh echo lsb-release -a FILES
/etc/motd, /var/run/motd, /etc/update-motd.d SEE ALSO
motd(5), pam_motd(8), run-parts(8) AUTHOR
This manpage and the update-motd framework was written by Dustin Kirkland <kirkland@canonical.com> for Ubuntu systems (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 3 published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. update-motd 13 April 2010 update-motd(5)
All times are GMT -4. The time now is 12:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy