Sponsored Content
Top Forums Shell Programming and Scripting Variable value inconsistency on BASH and CSH Post 302305281 by pavanlimo on Wednesday 8th of April 2009 11:48:41 AM
Old 04-08-2009
Quirkasaurus,
$data="123"
I want this to be concatenated with $input:
So the expected output would be:

"123abc".

This is happening as expected on BASH and also on KSH. CSH, like you said is creating a subshell and hence the variable value is not reflected.

I was hoping for inputs on some other approach to replace the current so that I can loop on the contents of a variable, line by line.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

From bash to csh and zsh

... Am I glad to find this forum (and vBulletin too, nice!).. OK, here's my issue. I have been handballed a bash script, not pretty but functional. I need to change to csh and zsh. For the csh I have the basics (e.g., such as change if/fi to if/endif, quote the variables, and bracket commands).... (10 Replies)
Discussion started by: lev_lafayette
10 Replies

2. Shell Programming and Scripting

different shell csh bash

I'm always having to work in the cshell, but occasionally want to run a command using bash. is that possible? I know I could write a shell script and call bash at the begining with #!/usr/bin/bash and then my command, is there another way? (1 Reply)
Discussion started by: ajp7701
1 Replies

3. Shell Programming and Scripting

how to make your bash script run on a machine with csh and bash

hi, i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
Discussion started by: npatwardhan
3 Replies

4. Shell Programming and Scripting

Bash one liner to CSH

Hello all, I have a Bash command I'm using on one system that replaces text in filenames, I'ts not working on another system that uses the Csh shell. Can anyone tell me what I need to do when i run for f in *;do mv $f ${f/text1/text2};done on the CSH shell i get ""Missing }."" (7 Replies)
Discussion started by: mike171562
7 Replies

5. UNIX for Dummies Questions & Answers

Running CSh scripts in Bash

Hi, I have some csh scripts and I want to run them in .bashrc. I use these techniques without any success: . test.csh or csh test.csh The first one assumed that the scripts is a bash script, so showed me errors. The second one finished without giving proper result. Can anybody offer... (6 Replies)
Discussion started by: mjdousti
6 Replies

6. Shell Programming and Scripting

Importing env from csh to bash

Hi All, In my account with csh shell, there are lots of env variables set and I want to import those all to bash in one stroke, is there any way to do it ? Thanks, D (1 Reply)
Discussion started by: Deei
1 Replies

7. Shell Programming and Scripting

Need a script to convert csh to bash

Hi, Can anyone give me a script to convert csh to bash? or any key points which can help me to do so as i am new to it. (3 Replies)
Discussion started by: vineet.dhingra
3 Replies

8. Shell Programming and Scripting

How to access the bash variables in csh

Hi, I am having a primary script which is Bash based. I am calling a csh script from it. Now, their are some variables defined in my bash script which i need in csh. I am unable to do so. Is it possible ? (2 Replies)
Discussion started by: vdhingra123
2 Replies

9. Ubuntu

error LD: undefined variable while changing shell from bash to csh

Hi, i am a beginner in ubuntu. my default shell is bash. everytime i try to change the shell with command "csh", i get a message (probably an error message). after i get into c-shell, when i try to execute a c shellscript, then it showed the same message. any idea about what is this about or any... (1 Reply)
Discussion started by: Avinash Nayak
1 Replies

10. Shell Programming and Scripting

Changing script from csh to bash

Hello Guys I have a script working fine on csh, but I would like to change it to bash, how I should change this command to be able to work as bash script. :wall: if ( $fsw > "0" ) then foreach swath ( `awk 'BEGIN {for (i='$fsw';i<='$lsw';i++) printf ("%s\n", i) }'` ) ## work to be done... (2 Replies)
Discussion started by: jiam912
2 Replies
stdatomic(3)						   BSD Library Functions Manual 					      stdatomic(3)

NAME
ATOMIC_VAR_INIT, atomic_init, atomic_load, atomic_store, atomic_exchange, atomic_compare_exchange_strong, atomic_compare_exchange_weak, atomic_fetch_add, atomic_fetch_and, atomic_fetch_or, atomic_fetch_sub, atomic_fetch_xor, atomic_is_lock_free -- type-generic atomic opera- tions SYNOPSIS
#include <stdatomic.h> _Atomic(T) v = ATOMIC_VAR_INIT(c); _Atomic T v = ATOMIC_VAR_INIT(c); void atomic_init(_Atomic(T) *object, T value); T atomic_load(_Atomic(T) *object); T atomic_load_explicit(_Atomic(T) *object, memory_order order); void atomic_store(_Atomic(T) *object, T desired); void atomic_store_explicit(_Atomic(T) *object, T desired, memory_order order); T atomic_exchange(_Atomic(T) *object, T desired); T atomic_exchange_explicit(_Atomic(T) *object, T desired, memory_order order); _Bool atomic_compare_exchange_strong(_Atomic(T) *object, T *expected, T desired); _Bool atomic_compare_exchange_strong_explicit(_Atomic(T) *object, T *expected, T desired, memory_order success, memory_order failure); _Bool atomic_compare_exchange_weak(_Atomic(T) *object, T *expected, T desired); _Bool atomic_compare_exchange_weak_explicit(_Atomic(T) *object, T *expected, T desired, memory_order success, memory_order failure); T atomic_fetch_add(_Atomic(T) *object, T operand); T atomic_fetch_add_explicit(_Atomic(T) *object, T operand, memory_order order); T atomic_fetch_and(_Atomic(T) *object, T operand); T atomic_fetch_and_explicit(_Atomic(T) *object, T operand, memory_order order); T atomic_fetch_or(_Atomic(T) *object, T operand); T atomic_fetch_or_explicit(_Atomic(T) *object, T operand, memory_order order); T atomic_fetch_sub(_Atomic(T) *object, T operand); T atomic_fetch_sub_explicit(_Atomic(T) *object, T operand, memory_order order); T atomic_fetch_xor(_Atomic(T) *object, T operand); T atomic_fetch_xor_explicit(_Atomic(T) *object, T operand, memory_order order); _Bool atomic_is_lock_free(const _Atomic(T) *object); DESCRIPTION
The header <stdatomic.h> provides type-generic operations on atomic operations. Atomic variables are declared using the _Atomic() type specifier or the _Atomic type qualifier. Such variables are not type-compatible with their non-atomic counterparts and may have different alignment. Operations on atomic variables that do not use the atomic_() interfaces, including compound assignment operations, will behave as if the non-_explicit() versions of those interfaces had been used. The atomic_init() operation initializes the atomic variable object with value. Atomic variables can be initialized while being declared using ATOMIC_VAR_INIT(). The atomic_load() operation returns the value of atomic variable object. The atomic_store() operation sets the atomic variable object to the desired value. The atomic_exchange() operation combines the behaviour of atomic_load() and atomic_store(). It sets the atomic variable object to the desired value and returns the original contents of the atomic variable. The atomic_compare_exchange_strong() operation stores the desired value into atomic variable object, but only if the atomic variable is equal to the expected value. Upon success, the operation returns true. Upon failure, the expected value is overwritten with the contents of the atomic variable and false is returned. The atomic_compare_exchange_weak() operation is identical to atomic_compare_exchange_strong(), but is allowed to fail even if atomic variable object is equal to the expected value. When an atomic_compare_exchange() operation is in a loop, the weak version will yield better perfor- mance on some platforms. When atomic_compare_exchange_weak() would require a loop and atomic_compare_exchange_strong() would not, the strong version is preferable. The atomic_fetch_add() operation adds the value operand to atomic variable object and returns the original contents of the atomic variable. The atomic_fetch_and() operation applies the and operator to atomic variable object and value operand and stores the result into object, while returning the original contents of the atomic variable. The atomic_fetch_or() operation applies the or operator to atomic variable object and value operand and stores the result into object, while returning the original contents of the atomic variable. The atomic_fetch_sub() operation subtracts the value operand from atomic variable object and returns the original contents of the atomic variable. The atomic_fetch_xor() operation applies the xor operator to atomic variable object and value operand and stores the result into object, while returning the original contents of the atomic variable. The atomic_is_lock_free() operation returns whether atomic variable object uses locks to implement atomic operations. MEMORY ORDER
C11 defines a memory model that may allow for the reordering of operations in the absence of fences or explicit memory ordering operations. The non-_explicit() interfaces use the strictest available memory order: sequential consistency. The _explicit() interfaces allow for config- uration of the memory order operation which is present. The types of available memory order operations are explained in more detail in ISO/IEC 9899:2011 (``ISO C11''). The order parameter of the _explicit() interfaces can have one of the following values: memory_order_relaxed Operation does not order memory. memory_order_consume Performs a consume operation. memory_order_acquire Performs an acquire operation. memory_order_release Performs a release operation. memory_order_acq_rel Performs both an acquire and a release operation. memory_order_seq_cst Provides sequential consistency. SEE ALSO
atomic(3), pthread(3) STANDARDS
These interfaces conform to ISO/IEC 9899:2011 (``ISO C11''). BSD
December 27, 2011 BSD
All times are GMT -4. The time now is 08:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy