Sponsored Content
Top Forums Shell Programming and Scripting FOR loop problem: Kindly Help Post 302139372 by okdev on Friday 5th of October 2007 04:55:47 PM
Old 10-05-2007
Continuation Problem

Once i find PROJECT matched & project VERSION matched. I am supposed to update $f3 & $f4 (3rd & 4th field) of same file.

Example:
reference.txt
Quote:
wahabeua |3.1 |wahabeua-1.1.11 |Not available |Code Coverage
ferrari12 |4.0 |ferrari12-1.1.21|Not applicable |Code Coverage
masterpiece |4.1 |masterpiece-2.2.33 |File Changes |Code Coverage
New Project with following variables (I have)
Quote:
PROJECT=ferrari12
VERSION=4.0
LABLE=ferrari12-1.1.25
Reference.txt should look like follwing.

Quote:
wahabeua |3.1 |wahabeua-1.1.11 |Not available |Code Coverage
ferrari12 |4.0 |ferrari12-1.1.25|Not applicable |Code Coverage
masterpiece |4.1 |masterpiece-2.2.33 |File Changes |Code Coverage
Code:
Quote:
#!/bin/sh

PROJECT=ferrari12
VERSION=4.0
LABLE=ferrari12-1.1.25

n=1 # Line Number

oldIFS="$IFS"
IFS='|'
while read f1 f2 f3 etc
do
if [ $f1 == $PROJECT ];then
echo "Line $n: Project Matched"
if [ $f2 == $VERSION ];then
echo " Version Matched"
sed 's/$f3/$LABLE/' # Lable Replaced
else
echo " Version Not Matched"
fi
else
echo "Line $n: New Project"
fi
let "n += 1"
done < reference.txt
IFS="$oldIFS"
some how sed is not working for me there to replace lable. Do you have some logic to fit in this loop.

Please Help! Thanks Smilie
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can someone kindly help with appending problem!!!

Hi guys,i urgently need help in this problem,i need to append one sentence to another line when it meet a certain word. For example: root: root time_last_login = 1191232080 root tty_last_login = /dev/vty0 root host_last_login = rep1nim root unsuccessful_login_count = 0 root... (10 Replies)
Discussion started by: cyberray
10 Replies

2. Shell Programming and Scripting

Kindly help : sort

Iam new to Unix ....analyzing the code Can any one pls explain what does it mean by below code sort +0 -1 +1 -2 +2 -3n +3 -4n +4 -5n file.txt -o awaiting for reply ..... (1 Reply)
Discussion started by: charandevu
1 Replies

3. Shell Programming and Scripting

kindly help me out on this please

Hello experts, please help me on this. This is the scenario: I have applications like BigBrother,PowerKeeper/PowerBroker etc.. which I have to install during server build for both AIX and Solaris. I already have separate installation scripts for both OS for all applications. Now, I want to... (0 Replies)
Discussion started by: solaix14
0 Replies

4. HP-UX

I am new to HPUX so kindly provide information related to it

Hello Gurus I am new to HPUX so kindly help me by providing information related to HPUX. I would like to know the date when HPUX 11i v3 comes in to market as well as I have H3056S student guide dated May 2005 which I download through some site. Now I want to know its a HPUX 11i v2 or HPUX 11i... (8 Replies)
Discussion started by: amity
8 Replies

5. Solaris

CJS instalation one problem...kindly help

hi am installing CJS frm one server to a cleint and i first did ./add_install_client -e now i need to know the mac add of the client so i entered into client and now hopw can i go to ok prmt ^] when this symbol is entered am nt being able to enter to ok promt what to do i... (1 Reply)
Discussion started by: all_is_well
1 Replies

6. Post Here to Contact Site Administrators and Moderators

kindly move thread

kindly move this thread: https://www.unix.com/unix-dummies-questions-answers/176868-get-all-strings-after-equal-sign.html to Shell Programming and Scripting...created in wrong forum... thanks!!! (0 Replies)
Discussion started by: h0ujun
0 Replies

7. Shell Programming and Scripting

FTP Transfer fails at first time. Kindly help

This is the command we use to transfer the file to destination we ran this command from batch job. first time it hangs. when we cancel and ran it again it works in 5 sec. anyone come out without solution..? ftp -n destinationftp << CMDEND user user/passwd lcd ${root}path cd path put... (1 Reply)
Discussion started by: shenthil76
1 Replies

8. Shell Programming and Scripting

Kindly Help regarding sorting a file rows

Dear All, I have a file name exporting.txt. Below is the content. $ cat exporting.txt . . exporting table DT_BCD 63716 rows exported . . exporting table DT_CVD 36321 ... (2 Replies)
Discussion started by: sudiptabhaskar
2 Replies
SHELL-QUOTE(1)						User Contributed Perl Documentation					    SHELL-QUOTE(1)

NAME
shell-quote - quote arguments for safe use, unmodified in a shell command SYNOPSIS
shell-quote [switch]... arg... DESCRIPTION
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands or files with embedded white space or shell globbing characters safely. Here are a few examples. EXAMPLES
ssh preserving args When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and passes them to "$SHELL -c". This doesn't work as intended: ssh host touch 'hi there' # fails It creates 2 files, hi and there. Instead, do this: cmd=`shell-quote touch 'hi there'` ssh host "$cmd" This gives you just 1 file, hi there. process find output It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote: eval set -- `find -type f -print0 | xargs -0 shell-quote --` debug shell scripts shell-quote is better than echo for debugging shell scripts. debug() { [ -z "$debug" ] || shell-quote "debug:" "$@" } With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can. save a command for later shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are things the user can't pass through), you can do something like this: user_switches= while [ $# != 0 ] do case x$1 in x--pass-through) [ $# -gt 1 ] || die "need an argument for $1" user_switches="$user_switches "`shell-quote -- "$2"` shift;; # process other switches esac shift done # later eval "shell-quote some-command $user_switches my args" OPTIONS
--debug Turn debugging on. --help Show the usage message and die. --version Show the version number and exit. AVAILABILITY
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions. AUTHOR
Roderick Schertler <roderick@argon.org> perl v5.16.3 2010-06-11 SHELL-QUOTE(1)
All times are GMT -4. The time now is 10:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy