All Questions
19 questions
0
votes
3
answers
318
views
view my lowercase shell variables from a bash function using awk
Outcome
Filter output the variables displayed using set or declare to show only lowercase named shell variables which is the convention I use for setting shell variables while testing.
Example
I set ...
0
votes
2
answers
9k
views
Save results from awk to a variable
I have a variable (that contains multiple lines of text) that I'm modifying using awk to replace the whitespace between fields with a comma and I'm trying to save it to another variable. This is what ...
0
votes
1
answer
1k
views
How can I keep an extracted value in a variable in bash
I have to extract certain values from some filenames in a directory and I wish to have a command to keep the extracted value in a variable. Say my files have the format place.type-date.log and I wish ...
-1
votes
2
answers
322
views
using awk to print if any three variables are true
I want the code print if any of these variables are true.
this is not my real code, it's just an example
read -p "enter protocol: " protocol
read -p "enter src ip: " srcip
read -p &...
1
vote
2
answers
257
views
use IF statment in AWK
i'm working on big script and i'm stucking in this part, if anyone can help me please
this is the file sample
31:49.9,9.92,TCP ,1_19,490,EXT_SERVER,22,5,257,1,.ASF,0,normal
and this is the part of my ...
1
vote
1
answer
2k
views
How can I use a variable in awk command
With my code I am trying to sum up the values with the specific name of a column in a csv file, depending on the input of the name.
Here's my code:
#!/bin/bash
updatedata() {
index=0
while ...
2
votes
2
answers
1k
views
Search for a String in a file and save the string after it to a variable
Example:
Lets say this is in a file:
AB: Test CD: Testing EF: Rest
I want a script to search for CD and save "Testing" into a variable.
I've tried something with awk but somehow I'm not making any ...
4
votes
1
answer
817
views
Prevent awk from removing "\" (backslashes) in variable
I have this line of code for the shell:
ls -1 *.mp3| awk -v here="$(cygpath -w $PWD)" -v source="$source" '{print "File Name: "$0"\n"here"\n"source}'
Unfortunately it outputs:
File Name: Data 00053....
0
votes
0
answers
431
views
How can I prepend the value of a variable to a column in bash? [duplicate]
I have a script that outputs a column of text. I want to prepend each entry in the column with a string stored as a variable. How can I do this?
For example, consider the command
$ echo -e "john\...
-6
votes
2
answers
1k
views
How to check if integer value is less or more then 3
We have two values
$a
$b
we need to compare the $a value with $b value
in case $b value is less than ($a - 3) or more than ($a + 3), then it will print fail.
example:
a=10
b=14
then it should ...
1
vote
1
answer
145
views
Why is Awk messing up my script variables
I really don't know why my variables are getting messed up, but I suspect the cause is awk. I've condensed this problem down to a small script:
#!/usr/bin/env bash
QUE_FILE="/mnt/drive4-4/private/...
2
votes
1
answer
1k
views
How can one prepend text to each line of a multi-line variable?
I print all the variables with there values
echo "$val"
mapreduce.map.memory.mb,3584
mapreduce.map.java.opts,-Xmx2560m
mapreduce.reduce.memory.mb,3584
mapreduce.reduce.java.opts,-Xmx2560m
...
2
votes
5
answers
139
views
bash + how to verify words are in list of values
how to identify that all values in parameter - var_general are in var_get
for example
var_general="sdb sdc sdd sde sdf sdg"
var_get="sdb sdc sdd sde sdf sdg sdh sdi"
according to this example will ...
1
vote
1
answer
1k
views
Command with multiple variables
I am trying to make the command to return the disk usage on the folders that occupy 1+ GiBs, but somehow the second variable in the command only prints out the value of first variable. Also, the ...
0
votes
2
answers
1k
views
using awk with variables [duplicate]
I am making a word list from all the words typed into a program that will be working with the text entered into it. I want to use a stream editor like sed or awk to search the first word of every ...