Sponsored Content
Top Forums Shell Programming and Scripting [Solved] BASH - chaining TEST and COMMAND with && and II Post 302725359 by jcdole on Friday 2nd of November 2012 06:28:46 AM
Old 11-02-2012
[Solved] BASH - chaining TEST and COMMAND with && and II

Can you explain what this line of script is doing.
What I have understood is :
-- variable C is the name of a software which is either not installed, so it must be installed or allready installed and then should be update if newer version found
-- branch B="$B $C" is to install the software
-- branch D="$D $C" is to update the software

How does [ "$A" == "0" ] && B="$B $C" || D="$D $C" works ?
Code:
A="0" or not
B=""
C="a_software-5.4.3-7.x86_64.rpm"
D=""
#
Download_the_package_and_put_it_in_tmp_directory   $C
#
if [ -f /tmp/$C ] ; then
    [ "$A" == "0" ] && B="$B $C" || D="$D $C"
else
        echo "Package not found"
fi

Help would be appreciated.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sleep 10 && command doesn't work

Hi there, I found a trick to easily postpone a command by a few seconds: supernova:~# sleep 10 && command &If you logout, the command should still be executed... But not all the time. Could anyone of you explain me why the following command is executed even after logging out: supernova:~# sleep... (2 Replies)
Discussion started by: chebarbudo
2 Replies

2. UNIX for Dummies Questions & Answers

Problem with xterm & tcsh & sourcing a script in a single command

Hi friends, I have a script that sets the env variable path based on different conditions. Now the new path variable setting should not done in the same terminal or same shell. Only a new terminal or new shell should have the new path env variable set. I am able to do this only as follows: >cd... (1 Reply)
Discussion started by: sowmya005
1 Replies

3. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

4. Shell Programming and Scripting

replace & with & xml file

Hello All I have a xml file with many sets of records like this <mytag>mydata</mytag> <tag2>data&</tag2> also same file can be like this <mytag>mydata</mytag> <tag2>data&</tag2> <tag3>data2&amp;data3</tag3> Now i can grep & and replace with &amp; for whole file but it will replace all... (4 Replies)
Discussion started by: lokaish23
4 Replies

5. Shell Programming and Scripting

Replace & sign to &amp word

Hi, I have text file abc.txt. In this file, I have the following data. Input: Mr Smith &amp Mrs Smith Mr Smith &apos Mrs Smith Mr Smith & Mrs Smith Mr Smith& Mrs Smith Mr Smith &Mrs Smith Output: Mr Smith &amp Mrs Smith Mr Smith &apos Mrs Smith Mr Smith &amp Mrs Smith Mr Smith&amp... (4 Replies)
Discussion started by: naveed
4 Replies

6. Shell Programming and Scripting

bash aliases and command chaining with ; (semi-colon)

What am I doing wrong here? Or is this not possible? A bug? alias f='find . >found 2>/dev/null &' f ; sleep 20 ; ls -l -bash: syntax error near unexpected token `;' (2 Replies)
Discussion started by: star_man
2 Replies

7. UNIX for Dummies Questions & Answers

[solved] Where & what bash env file, Mac OS?

Hi! I wanted to simplify my bash prompt, so I edited my etc/bashrc file. I thought this was the file that would override any other env files. When I opened it, I saw that the way it was setup was not what my prompt looked like, although I forget exactly what was there. But i edited it the way I... (1 Reply)
Discussion started by: sudon't
1 Replies

8. Shell Programming and Scripting

Read input while another command is running &&

This script runs tshark, then displays the output. I want to read a keypress at all times throughout this script, especially during the 10 seconds that tshark is running. This code however, only takes input before tshark runs. #!/bin/bash main() { while (( "1" == "1" )) ; do keypress &&... (3 Replies)
Discussion started by: Kiah07
3 Replies

9. Shell Programming and Scripting

If && command giving wrong output

Hi All, I am trying to run a script which will search for 2 strings(stopped,started) in a text file and echo an output depending on below condition -bash-3.2$ cat trial1.txt v ggg f -bash-3.2$ cat trial1.sh VAR9=` grep 'stopped' /tmp/trial1.txt` VAR10=` grep 'started'... (4 Replies)
Discussion started by: srkmish
4 Replies

10. Shell Programming and Scripting

SFTP Shell Script Get & Delete && Upload & Delete

Hi All, Do you have any sample script, - auto get file from SFTP remote server and delete file in remove server after downloaded. - only download specify filename - auto upload file from local to SFTP remote server and delete local folder file after uploaded - only upload specify filename ... (3 Replies)
Discussion started by: weesiong
3 Replies
GBP-PULL(1)						      git-buildpackage Manual						       GBP-PULL(1)

NAME
gbp-pull - Safely update a repository from remote SYNOPSIS
gbp-pull [ --verbose ] [ --force ] [ --redo-pq ] [ --[no-]pristine-tar ] [ --debian-branch=branch_name ] [ --upstream-branch=branch_name ] [ --depth=depth ] DESCRIPTION
gbp-pull updates the debian, upstream and pristine-tar branches from a remote repository in one go. It checks if the update is safe (would result in a fast-forward merge) and aborts otherwise. OPTIONS
--force force a branch update even if this results in a non fast forward update. Warning: Forcing a branch updates makes you lose your modifications. --redo-pq also rebuild the corresponding patch-queue using gbp-pq. Warning: This drops the patch-queue branch if it exists. --debian-branch=branch_name The branch in the Git repository the Debian package is being developed on, default is master. --upstream-branch=branch_name The branch in the Git repository the upstream sources are put onto. Default is upstream. --depth=depth Git history depth, for deepening shallow git clones. --verbose -v verbose execution --pristine-tar Whether to update the pristine-tar branch too. EXIT CODES
When gbp-pull finishes it indicates success or failure with it's exit code: 0 Success. 1 An error occured during the pull, see the printed error message for details. 2 At least one branch couldn't be fast forwarded. CONFIGURATION FILES
Several gbp.conf files are parsed to set defaults for the above commandline arguments. See the [XRef to GBP.MAN.GBP.CONF] manpage for details. SEE ALSO
git-buildpackage(1), gbp-clone(1), gbp-pq(1), gbp.conf(5) AUTHOR
Guido Guenther <agx@sigxcpu.org> 01 June 2012 GBP-PULL(1)
All times are GMT -4. The time now is 03:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy