Sponsored Content
Top Forums UNIX for Beginners Questions & Answers C shell concatenate string doesn't work Post 303042734 by student_wiz on Sunday 5th of January 2020 08:52:37 AM
Old 01-05-2020
C shell concatenate string doesn't work

I have the following code:

Code:
#!/bin/csh
clear
set cloud_file="/home/labs/koren/davidsr/general_scripts/MFP_10_PP_Parmas.txt" # to fill
set mie_tables_dir='/home/labs/koren/davidsr/SHDOM_MAIN/MIE_TABLES/non_polo_wave_0.7_water_50R_s0.5_e25_max_70.mie' # to fill
set prp_dir='${pp_dir}/pp_prp/'
set num_lwp=7 # to fill
set num_r=3 # to fill
#for each wavelength


foreach wav (0.7 1.61)
	echo "current wavelength is: $wav"
	set iter=1
	while ($iter <= $num_r)
		@ last_line=$iter * $num_lwp + $iter
		@ first_line=$last_line - $num_lwp
		@ second_line=$first_line + 1
		
		set R_eff=`awk "NR==$first_line {print}" $cloud_file`
		set LWP=`awk "NR==$second_line, NR==$last_line {print}" $cloud_file`
		@ iter++
		foreach r ($R_eff)
			set r=$r | tr "\n" " "
			set r=$r | tr "\r" " "
			echo "current radius is: $r"
			foreach lwp ($LWP)
				set lwp=$lwp | tr "\n" " "
				set lwp=$lwp | tr "\r" " "
				echo "current lwp is: $lwp"
                		# echo "${prp_name}"
                		# prp_name+="${prp_name}_Re_${r}"
                		# echo "${prp_name}"
                		# set prp_name3="${prp_name2}_wav_${wav}"
                		# echo "${prp_name3}"
				set prp_name="pp_LWP_${lwp}_Re_${r}_wav_${wav}.prp"
				echo "${prp_name}"
			end
		end
	end
end

which the cloud file looks like:
Code:
1.0
39.999
80.001
120.0
159.999
200.001
240.0
279.999
2.0
39.999
80.001
120.0
159.999
200.001
240.0
279.999

although it should print the prp_name as constructed above I get the following:
Code:
current radius is: 3.0
current lwp is: 39.999
_wav_1.61.prp
current lwp is: 80.001
_wav_1.61.prp
current lwp is: 120.0
_wav_1.61.prp
current lwp is: 159.999
_wav_1.61.prp9
current lwp is: 200.001
_wav_1.61.prp1
current lwp is: 240.0
_wav_1.61.prp
current lwp is: 279.999
_wav_1.61.prp9

I couldn't fix the issue, would appreciate some help

Last edited by vbe; 01-05-2020 at 06:03 PM.. Reason: more code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep doesn't work within shell script?

I am trying to run the following code from a script file but it complains that syntax of (both instances of) grep is wrong. When I copy and paste it to the terminal, it is OK. Any idea what the problem might be? set i = `grep -c #define flags.h` while ($i>20) @ i-- my func (`cat... (4 Replies)
Discussion started by: barisgultekin
4 Replies

2. Shell Programming and Scripting

How to concatenate two strings or several strings into one string in B-shell?

like connect "summer" and "winter" to "summerwinter"? Can anybody help me? thanks a lot. (2 Replies)
Discussion started by: fontana
2 Replies

3. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script RemoveFiles.sh Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies

4. Shell Programming and Scripting

Perl cmds doesn't work in Bash shell . Plz help

Hi everyone, I have a Linux OS in my PC (older version 9). Its default shell is bash. Whenever I try to run some Perl program it throws error ! eg, if I run this simple PERL program , #!/usr/bin/perl printf "\lHello \n"; $var=3 ; printf $var; @list=(1,2,3); printf "@list";... (6 Replies)
Discussion started by: adc22
6 Replies

5. Shell Programming and Scripting

shell script, echo doesn't work

#!/bin/sh something(){ echo "Inside something" echo $1 $2 } val=$(something "Hello " "world") Output expected: Inside somethingHello world But it's not echoing. (4 Replies)
Discussion started by: cola
4 Replies

6. Shell Programming and Scripting

Replace string with sed doesn't work

Hello, Unfortunately I don't found any working solution for my problem :/ I have pass file for dovecot authorizing in this format: user@domain.tld:{SSHA}Ykx2KVG/a2FKzjnctFFC2qFnrk9nvRmW:5000:5000:::: . . ...Now, I want to write some sh script for password changing for grep'ed user, in... (5 Replies)
Discussion started by: vincenty
5 Replies

7. UNIX for Dummies Questions & Answers

find command in shell script doesn't work

Hello all, Something strange going on with a shell script I'm writing. It's trying to write a list of files that it finds in a given directory to another file. But I also have a skip list so matching files that are in that skip list should be, well uhm, skipped :) Here's the code of my... (2 Replies)
Discussion started by: StijnV
2 Replies

8. Shell Programming and Scripting

Switching user inside a shell script doesn't seem to work

Linux version : Oracle Linux 6.4 Shell : Bash The following script will be run as root. During the execution, it should switch to oracle user and execute few commands. After googling and searching within unix.com , I came up with the following syntax ## Enclosing all commands in double... (7 Replies)
Discussion started by: John K
7 Replies

9. HP-UX

Su to another user from root doesn't work within shell script

Hello I have a shell script that is run as root. Script rins ok until the point where it have to switch to user "mqm" to run other commands. It just hangs at the point of this line in the script su - mqm -c "dspmq" I ran the same commands at the terminal and they run fine. Any thoughts. (6 Replies)
Discussion started by: mo12
6 Replies

10. UNIX for Beginners Questions & Answers

Concatenate a string and number and compare that with another string in awk script

I have below code inside my awk script if ( $0 ~ /SVC IN:/ ) { svc_in=substr( $0,23 , 3); if (msg_start == 1 && msg_end == 0) { msg_arr=$0; } } else if ( $0 ~ /^SVC OUT:/ ) { svc_out=substr( $0, 9, 3); if (msg_start == 1 && msg_end == 0) ... (6 Replies)
Discussion started by: bhagya123
6 Replies
Gtk2::TextIter(3)					User Contributed Perl Documentation					 Gtk2::TextIter(3)

NAME
Gtk2::TextIter HIERARCHY
Glib::Boxed +----Gtk2::TextIter METHODS
textattributes = $iter->get_attributes boolean = $iter->backward_char boolean = $iter->backward_chars ($count) o $count (integer) boolean = $iter->backward_cursor_position boolean = $iter->backward_cursor_positions ($count) o $count (integer) boolean = $iter->backward_find_char ($pred, $user_data=undef, $limit=undef) o $pred (scalar) o $user_data (scalar) o $limit (Gtk2::TextIter or undef) boolean = $iter->backward_line boolean = $iter->backward_lines ($count) o $count (integer) (match_start, match_end) = $iter->forward_search ($str, $flags, $limit=NULL) o $str (string) o $flags (Gtk2::TextSearchFlags) o $limit (Gtk2::TextIter or undef) boolean = $iter->backward_sentence_start boolean = $iter->backward_sentence_starts ($count) o $count (integer) boolean = $iter->backward_to_tag_toggle ($tag) o $tag (Gtk2::TextTag or undef) boolean = $iter->backward_visible_cursor_position Since: gtk+ 2.4 boolean = $iter->backward_visible_cursor_positions ($count) o $count (integer) Since: gtk+ 2.4 boolean = $iter->backward_visible_line Since: gtk+ 2.8 boolean = $iter->backward_visible_lines ($count) o $count (integer) Since: gtk+ 2.8 boolean = $iter->backward_visible_word_start Since: gtk+ 2.4 boolean = $iter->backward_visible_word_starts ($count) o $count (integer) Since: gtk+ 2.4 boolean = $iter->backward_word_start boolean = $iter->backward_word_starts ($count) o $count (integer) boolean = $iter->begins_tag ($tag) o $tag (Gtk2::TextTag or undef) textbuffer = $iter->get_buffer integer = $iter->get_bytes_in_line boolean = $iter->can_insert ($default_editability) o $default_editability (boolean) character = $iter->get_char integer = $iter->get_chars_in_line textchildanchor or undef = $iter->get_child_anchor integer = $lhs->compare ($rhs) o $rhs (Gtk2::TextIter) boolean = $iter->editable ($default_setting) o $default_setting (boolean) boolean = $iter->ends_line boolean = $iter->ends_sentence boolean = $iter->ends_tag ($tag) o $tag (Gtk2::TextTag or undef) boolean = $iter->ends_word boolean = $lhs->equal ($rhs) o $rhs (Gtk2::TextIter) boolean = $iter->forward_char boolean = $iter->forward_chars ($count) o $count (integer) boolean = $iter->forward_cursor_position boolean = $iter->forward_cursor_positions ($count) o $count (integer) boolean = $iter->forward_find_char ($pred, $user_data=undef, $limit=undef) o $pred (scalar) o $user_data (scalar) o $limit (Gtk2::TextIter or undef) boolean = $iter->forward_line boolean = $iter->forward_lines ($count) o $count (integer) (match_start, match_end) = $iter->forward_search ($str, $flags, $limit=NULL) o $str (string) o $flags (Gtk2::TextSearchFlags) o $limit (Gtk2::TextIter or undef) boolean = $iter->forward_sentence_end boolean = $iter->forward_sentence_ends ($count) o $count (integer) $iter->forward_to_end boolean = $iter->forward_to_line_end boolean = $iter->forward_to_tag_toggle ($tag) o $tag (Gtk2::TextTag or undef) boolean = $iter->forward_visible_cursor_position Since: gtk+ 2.4 boolean = $iter->forward_visible_cursor_positions ($count) o $count (integer) Since: gtk+ 2.4 boolean = $iter->forward_visible_line Since: gtk+ 2.8 boolean = $iter->forward_visible_lines ($count) o $count (integer) Since: gtk+ 2.8 boolean = $iter->forward_visible_word_end Since: gtk+ 2.4 boolean = $iter->forward_visible_word_ends ($count) o $count (integer) Since: gtk+ 2.4 boolean = $iter->forward_word_end boolean = $iter->forward_word_ends ($count) o $count (integer) boolean = $iter->has_tag ($tag) o $tag (Gtk2::TextTag) boolean = $iter->in_range ($start, $end) o $start (Gtk2::TextIter) o $end (Gtk2::TextIter) boolean = $iter->inside_sentence boolean = $iter->inside_word boolean = $iter->is_cursor_position boolean = $iter->is_end boolean = $iter->is_start language = $iter->get_language integer = $iter->get_line integer = $iter->get_line_index $iter->set_line_index ($byte_on_line) o $byte_on_line (integer) integer = $iter->get_line_offset $iter->set_line_offset ($char_on_line) o $char_on_line (integer) $iter->set_line ($line_number) o $line_number (integer) list = $iter->get_marks Returns a list of all Gtk2::TextMark at this location. Because marks are not iterable (they don't take up any "space" in the buffer, they are just marks in between iterable locations), multiple marks can exist in the same place. The returned list is not in any meaningful order. integer = $iter->get_offset $iter->set_offset ($char_offset) o $char_offset (integer) $first->order ($second) o $second (Gtk2::TextIter) pixbuf or undef = $iter->get_pixbuf string = $start->get_slice ($end) o $end (Gtk2::TextIter) boolean = $iter->starts_line boolean = $iter->starts_sentence boolean = $iter->starts_word list = $iter->get_tags Returns a list of tags that apply to iter, in ascending order of priority (highest-priority tags are last). string = $start->get_text ($end) o $end (Gtk2::TextIter) list = $iter->get_toggled_tags ($toggled_on) o $toggled_on (boolean) Returns a list of Gtk2::TextTag that are toggled on or off at this point. (If toggled_on is TRUE, the list contains tags that are toggled on.) If a tag is toggled on at iter, then some non-empty range of characters following iter has that tag applied to it. If a tag is toggled off, then some non-empty range following iter does not have the tag applied to it. boolean = $iter->toggles_tag ($tag) o $tag (Gtk2::TextTag or undef) integer = $iter->get_visible_line_index $iter->set_visible_line_index ($byte_on_line) o $byte_on_line (integer) integer = $iter->get_visible_line_offset $iter->set_visible_line_offset ($char_on_line) o $char_on_line (integer) string = $start->get_visible_slice ($end) o $end (Gtk2::TextIter) string = $start->get_visible_text ($end) o $end (Gtk2::TextIter) ENUMS AND FLAGS
flags Gtk2::TextSearchFlags o 'visible-only' / 'GTK_TEXT_SEARCH_VISIBLE_ONLY' o 'text-only' / 'GTK_TEXT_SEARCH_TEXT_ONLY' SEE ALSO
Gtk2, Glib::Boxed COPYRIGHT
Copyright (C) 2003-2008 by the gtk2-perl team. This software is licensed under the LGPL. See Gtk2 for a full notice. perl v5.12.1 2010-07-05 Gtk2::TextIter(3)
All times are GMT -4. The time now is 05:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy