Search Results

Search: Posts Made By: popeye
7,313
Posted By Scrutinizer
If you use the variable FILES, then when when you...
If you use the variable FILES, then when when you expand it, it becomes susceptible to field splitting by the shell and that can break your script if there are files that contain spaces..

Either...
1,500
Posted By RudiC
How about awk '/^ *interface/ {IF = $0}...
How about
awk '/^ *interface/ {IF = $0} /helper/ {if (IF) print IF; IF = ""; print}' file
interface Vlan3
ip helper-address 192.168.228.188
ip helper-address 192.168.97.199
ip helper-address...
2,245
Posted By Corona688
We will not know exactly what you mean unless you...
We will not know exactly what you mean unless you copy-paste the output of it misbehaving.

Also, from earlier:
2,245
Posted By DGPickett
I'd "double quote" the $variables so the script...
I'd "double quote" the $variables so the script does not fail for all whitespace in or shell sensitive characters.

You read 'theopt' but echo 'opt', which is never set.

Usually ':' prompts...
2,245
Posted By Corona688
I just realized something. By 'backspace' do you...
I just realized something. By 'backspace' do you mean 'goes to the beginning of the line'? Your file may have carriage returns in it. What have you been editing it with?
2,245
Posted By RudiC
I can't replicate the error that you report. Did...
I can't replicate the error that you report. Did you consider bash's select builtin?
2,245
Posted By Corona688
In what way does it not work? $...
In what way does it not work?


$ ./oneopt.sh
M A I N - M E N U
1. Contents of /etc/passwd
2. List of users currently logged
3. Prsent handling directory
4. Exit
Please enter option [1-4] :...
2,245
Posted By Corona688
Could you copy-paste the output of it...
Could you copy-paste the output of it misbehaving? I really don't understand what "like a backspace" means.

You could also do $ script
Script started, file is typescript
$ ./myscript.sh

......
1,563
Posted By Corona688
You posted that it didn't work. I took your word...
You posted that it didn't work. I took your word for it.

echo "${VAR//[()]/}"
991
Posted By ahamed101
Check this, illustrated with examples Bash...
Check this, illustrated with examples

Bash String (http://www.thegeekstuff.com/2010/07/bash-string-manipulation/)

HTH

--ahamed
1,688
Posted By MadeInGermany
#!/bin/ksh dosumtin () { date } #...
#!/bin/ksh
dosumtin () {
date
}

# store stdout of the following code in var
var=$(
for i in {1..5}
do
dosumtin
done
)

echo "$var"
1,688
Posted By Scrutinizer
@Lucas_0418: It is better to not leave the format...
@Lucas_0418: It is better to not leave the format argument of printf unspecified. Also if you use [@] instead of
you do not need to use tr and you could just do this:
printf "%s\n" "${DATE[@]}"...
1,688
Posted By Corona688
You don't need to open the same file 9 times to...
You don't need to open the same file 9 times to do 9 writes.



( echo "header"

for X in 1 2 3 4 5
do
echo "something $X"
done

echo "footer" ) > filename

To get the output of...
1,688
Posted By Lucas_0418
Hi popeye, '>>' redirect may can not used...
Hi popeye,
'>>' redirect may can not used to a variable instead of a file.
If need to saves all 5 of the subs execution responses in a var or an array.

This codes may works.

Array:...
1,688
Posted By sea
After appending 5 times the current date-string,...
After appending 5 times the current date-string, you're overwriting the $FILE with "this is my cheapfile" and then again overwrite it.. with itself...

I'd assume you wanted something like:
...
1,412
Posted By Perderabo
This doesn't seem to need any array. Here is...
This doesn't seem to need any array. Here is what I would do... (untested)

output=""
[[ "$prit" != "$tsver" ]] && output="${output}${prit}"
output="${output},"
[[ "$lt" != "$tsver" ]] &&...
1,539
Posted By bartus11
Try:@food = (%fruit, %veggies);
Try:@food = (%fruit, %veggies);
750
Posted By apmcd47
There is a built-in output field separator which...
There is a built-in output field separator which inserts a single space between your array elements. It is controlled by the variable $" so you can change it. See my example below:

$ cat...
2,239
Posted By Subbeh
You need to declare the variables using use vars...
You need to declare the variables using use vars for it to work:
use vars qw($opt_u $opt_p ...);
2,107
Posted By MR.bean
Assuming you have this input and you want the...
Assuming you have this input and you want the following output


$ cat xyz
primary
Factory CTS 1.9.0(46) P1
*Slot 1 CTS 1.10.2(42) P1
primary
Factory CTS 2.0.0(18) P1
*Slot 1 CTS 2.1.0(42)...
1,536
Posted By Smiling Dragon
Set a flag at the start, use a while loop based...
Set a flag at the start, use a while loop based on it, unset it once you are happy all is well.

my $redo=1;
while ($redo) {

<ask your questions>

print "Are these statements correct y or...
1,481
Posted By RudiC
grep -A5 "The list of char" file | diff -...
grep -A5 "The list of char" file | diff - blockfile
echo $?
0
7,370
Posted By in2nix4life
In Expect you can use "file exists" and/or "file...
In Expect you can use "file exists" and/or "file size" to get the status of a file:


#!/usr/bin/expect -f

set filename "/tmp/file"
set file_status [file exists $filename]
if { $file_status >...
1,093
Posted By MadeInGermany
If you read the entire file into an array you...
If you read the entire file into an array
you can print the array like that - without a loop.
@lines = <IN>;
print grep /\Q$ARGV[0]\E/, @lines;
Or even directly from the file
print grep...
Forum: Red Hat 06-20-2013
1
1,657
Posted By Yoda
Check wget manual...
Check wget manual (http://www.gnu.org/software/wget/manual/wget.html). Look for option --directory-prefix
Showing results 1 to 25 of 25

 
All times are GMT -4. The time now is 07:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy