Skip to main content

All Questions

-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 &...
peter louis's user avatar
1 vote
0 answers
194 views

Two lines are removed with sed instead of one, why? [duplicate]

I am attempting to remove lines from this text file (foo.txt): cat mouse animals: 2 I want to remove the two lines from the end: ‎ animals: 2 So I end up with this: cat mouse However, when using ...
leetbacoon's user avatar
2 votes
1 answer
9k views

How to read a file with two columns into a script so that each line read as two variables

I have a file that has two columns like such. cat test.txt 100 2007 FFF 1993 7E7 1994 4BB 1995 I need to input each of the lines into a script, and have the two columns assigned as separate ...
maclian's user avatar
  • 123
4 votes
4 answers
7k views

How to allow only certain characters in a bash variable

I want to prompt the user to input a URL, but it can only contain A-Z, a-z, 0-9, &, ., /, =, _, -, :, and ?. So, for example: Enter URL: $ http://youtube.com/watch?v=1234df_AQ-x That URL is ...
leetbacoon's user avatar
0 votes
3 answers
4k views

Map string from var1 to var2 (lookup)

I want to do case insensitive lookup on VAR2 based on the content of VAR1 that holds some parameters in the form key:value. If a VAR1 key is present replace the value in VAR2. For example for: VAR1=...
Nir's user avatar
  • 1,395
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 ...
yael's user avatar
  • 13.9k
3 votes
2 answers
1k views

Changing a number in a string of numbers

I'm trying to write a function that will let me change a number in a list of numbers based on a position. For example, I want to be able to change the fourth number in the list 10.90.123.80.42 to 19 ...
Adam L's user avatar
  • 33
0 votes
1 answer
2k views

Creating a file and replacing variables in bash

Background: I created a VPN service for myself. I have a lot of time on my hands and I enjoy the challenge of creating "business like" services, so I can kind of create a portfolio for myself. I ...
a b's user avatar
  • 9