10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I want to pass variable to below awk statement
awk '/abc123/{x=NR+1}(NR<=x){print}' sftp_log_20150317.log
I tried -v like below, but its not working. Please help!!!
awk -v var1="abc123" '/var1/{x=NR+1}(NR<=x){print}' sftp_log_20150317.log
Input file is:
sftp_log_20150317.log
... (3 Replies)
Discussion started by: vegasluxor
3 Replies
2. Shell Programming and Scripting
I am trying to set a variable from this AWK command in KSH but I keep getting an error that says my variable cannot be found.
LOADNO = $(awk -F"|" 'NR==1{print $2}' file.txt)
If I just run awk -F"|" 'NR==1{print $2}' file.txt I get the right value but as soon as I try to assign this... (1 Reply)
Discussion started by: cvigeant
1 Replies
3. UNIX for Dummies Questions & Answers
Hi,
when I enter 'ps -ef| grep process_name'/'psu | grep process_name', i am getting multiple number of lines output( i mean multiple no of processes).how can i store it one by one and echo it in the same way(one by one).
part of script is
var1=$(remsh hostname -l username ps -ef|grep... (2 Replies)
Discussion started by: jeanzibbin
2 Replies
4. Shell Programming and Scripting
Well, I think I've managed to take two different issues and conglomerate them into and embarrasing mess.
#!/bin/bash
# Set some variables
dir1=/path/that/isnt/variable/$variabledir/dir/
dir2=/path/that/isnt/variable/$variabledir/important/"$variabledir"-subdirectory/path/
echo "Gimme... (7 Replies)
Discussion started by: karlp
7 Replies
5. Shell Programming and Scripting
How do you store strings in a variable-sized array?
Background:
I wrote a program earlier today to work with a very large text file. I chose Perl because it lets me do some nice formatting on the text I grab, instead of just using a shell script to con'cat'enate egrep results.
The program... (2 Replies)
Discussion started by: CRGreathouse
2 Replies
6. UNIX for Dummies Questions & Answers
Wondering what $@ does - is it a variable of some kind? (1 Reply)
Discussion started by: Jayden
1 Replies
7. Shell Programming and Scripting
Hey guys I have here what I am sure amounts to a pretty dumb question.... how do I assign a value of say 999 to a variable called "random number" (note the space between random and number). What would the script look like using borne shell?
Thanks! :) (4 Replies)
Discussion started by: pattingtonjbear
4 Replies
8. Shell Programming and Scripting
set filename $logDir/PyLog/$logname
echo $filename >> logname.txt
I am trying to write to write the varibale filename into a file logname.txt,it is not working could any one suggest y (2 Replies)
Discussion started by: nathgopi214
2 Replies
9. Shell Programming and Scripting
hi
How can one change an environment varaible inside a shell script
say my bash shell has a env variable export FOO="Day"
no i want to write a script inside which the FOO variable is modified to say
export FOO=NIGHT
after this script finishes te bash shell should show me NIGHT when i... (1 Reply)
Discussion started by: wojtyla
1 Replies
10. Shell Programming and Scripting
Hi,
I have a program that searches for a particular string patten. I am however having difficulty passing the varible $i (in a loop) as the string pattern to replace. Using either perl or sed search and replace statements, I get the same kinda result. For example, using the perl:
for i in... (3 Replies)
Discussion started by: Breen
3 Replies