10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I have a script which intends to create as many variables at runtime, as the number of parameters passed to it. The script needs to save these parameter values in the variables created and print them
abc.sh
----------
export Numbr_Parms=$#
export a=1
while
do
export... (3 Replies)
Discussion started by: dev.devil.1983
3 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I need to pass the multiple values of src1 to another variable. I managed to print it but not sure how to assign it to a variable in a loop.
src1=01,02,03
echo $src1|awk 'BEGIN {FS=","} {for(i=1;i<=NF;i++) print $i}'
I need to pass the value as
src2=01
src2=02
src2=03
Thanks... (4 Replies)
Discussion started by: shash
4 Replies
3. Shell Programming and Scripting
Hi Forum.
I have the following test.txt file and need to extract certain rows based on "starting position", "length of string" and "string to search for":
1a2b3d
2a3c4d
.....
My script accepts 3 parameters: (starting col pos, length to search for, string to search for) and would like to... (4 Replies)
Discussion started by: pchang
4 Replies
4. Shell Programming and Scripting
I have a file that has 2 fields called b_file:
11977 DAR.V3.20150209.1.CSV
3295 DAR.V3.20150209.1.CSV
1721 DAR.V2.20150210.1.CSV
I need to search a sftplog using the field 1, but want to maintain the relationship between field 1 and 2. I am passing field 1 as a parameter in a bash loop.
... (14 Replies)
Discussion started by: smenago
14 Replies
5. Shell Programming and Scripting
I wrote a very simple script to understand how to call user-defined functions from within awk after reading this post.
function my_func_local {
echo "In func $1"
}
export -f my_func_local
echo $1 | awk -F"/" '{for (k=1;k<=NF;k++) {
if ($k == "a" ) {
system("my_local_func $k")
}
else{... (19 Replies)
Discussion started by: sreyan32
19 Replies
6. Programming
Hello,
I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this :
This is the output of ls command : I stored the output in a file filelist
1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies
7. Shell Programming and Scripting
Hello,
I have a case where I need to process an environment variable text value in CShell to calculate the product of 2 numbers stated in the variable string having the format "<first_number>Letter x<second_number>".
Ex: $VAR = "24x20"
I need to set $VAR_PRODUCT = "Product of 20 and 24"... (3 Replies)
Discussion started by: mohy
3 Replies
8. Shell Programming and Scripting
I'm an experienced awk user, but this one has me stumped. I have an awk script which is called from a UNIX command line as you'd expect:
myscript.awk -v foo=$1 -v bar=$2 filename
My question is this: is there a mechanism for determining the names of the -v variables within a script?
... (3 Replies)
Discussion started by: John Mac
3 Replies
9. UNIX for Dummies Questions & Answers
Does anybody know how to print a variable passed to awk command?
awk -F"|" 'BEGIN {print $job,"\n","Question \n"} {print $1,$2$4," ",$3}' "job=$job1" file1
I am trying to pass job the variable job1.
the output is blank.
?? (3 Replies)
Discussion started by: whatisthis
3 Replies
10. UNIX for Dummies Questions & Answers
Anybody know what's wrong with this syntax?
awk -v job="$job" 'BEGIN { FS="|"}
{print $1,$2," ",$4," ",$3\n,$5,"\n"}' list
It's keeping give me this message:
awk: syntax error near line 1
awk: bailing out near line 1
It seems awk has problem with my BEGIN command.
Any... (8 Replies)
Discussion started by: whatisthis
8 Replies