Questions tagged [ifs]

IFS is a variable in Unix shells (Bourne, POSIX sh, bash, ksh, …) that controls how unescaped substitutions are split into words.

IFS (short for "input field separator" and often referred to as "internal field separator") is a variable in Unix shells (, , , , , , , , …) that controls how strings are split into multiple fields. Most notably, variable substitutions (e.g. $foo) which are not inside double quotes or in a few other protected locations are split into multiple fields based on the value of IFS; the same goes for command substitutions (e.g. $(foo)). Each character that is present in IFS is a field separator. The default value contains a space, a tab and a newline.

For other meanings of the acronym IFS, use the appropriate tag:

  • IBM Integrated file system
  • QNX Image Filesystem
  • ERP by Industrial and Financial Systems AB
293 questions
0
votes
1 answer

IFS multiple cells with 'greater than' 'less than' condition in one cell

Good morning, If there is no value in B3 then the following calculation is needed, otherwise, the value in B3 should be used. =IFS(B1>1000,(B1-1000)*0.06+200,B1<1001,B1*0.06) But I can't seem to add B3="" to the beginning of the code without…
Nene
  • 55
  • 1
  • 7
0
votes
1 answer

How to name a specific sequence distinctivly in excel

I am having the following trouble. I have a set of data in excel which represents the route a bus has taken. Based on the route that the bus has taken, i want to determine if it is Route 1 or Route 2. The way that I can understand if the bus has…
0
votes
0 answers

passing positional parameters to bash function that contain a `.` dot

I have a function in bash foo () { # does some work } and I pass a parameter that contains a dot (for example hostnames contain dots) HOSTNAME=`hostname` # pretend its host.on.a.net foo $HOSTNAME When foo does work on HOSTNAME, it will split…
LeanMan
  • 474
  • 1
  • 4
  • 18
0
votes
2 answers

insert line on first instance of of a value

i am trying to insert a row on the first instance where the value in column y is above 60. Only one row. i did a loop to insert multiple rows for anything above 60 but i dont need this. having difficulty changing this here's what i got Dim Col…
0
votes
3 answers

Shell quotes with IFS in Jenkins Pipeline

I'm trying to set IFS in a Bash shell within a Jenkins pipeline script. See line 34 below. The problem is I can't get the multi-level quoting correct. If I'm just typing at a bash terminal, the line would be IFS=$'\n'. But, no matter how many…
Marc
  • 13
  • 4
0
votes
2 answers

Split comma separated string by ignoring spaces in front and back of delimiter and store in array in shell script

I need help to split string in bash script with delimiter ',' and ignore spaces in front and back of delimiter. My string looks like below and ',' is delimiter. mystring = < hostname1, hostname 2 , hostname value 3 > Notice that 1.…
rock
  • 25
  • 1
  • 1
  • 7
0
votes
3 answers

Google sheets: Returns "False" if the time is in the range from 23:00 to 05:00 (or from 11:00 PM to 05:00 AM)

My formula should return 4 different text values depending on what time value is in the cell. Everything would work fine, but every time I try to make the formula look at the time from 23:00 to 05:00, it always returns False or #N/A if in full…
Aizek
  • 59
  • 4
0
votes
0 answers

Is there an equivalent of `set -- $*` that works in both Bash and Zsh?

It seems the line in Bash set -- $* is to re-parse the argument using the new IFS. Example: try() { IFS=: set -- $* echo 1st, $1 echo 2nd, $2 echo 3rd, $3 } and then $ try a:b:c 1st, a 2nd, b 3rd, c because without that line,…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
0
votes
0 answers

Trying to replicate a function from excel to Tableau

My excel file contains a column which is called shape, so I am trying to replicate this formula in an excel file to the calculate de volume for each of my shapes. My idea was by using an ifs statement. Let me know what you think. Thanks! This is the…
JVA
  • 111
  • 4
  • 10
0
votes
2 answers

Using IFS with a negative number

I'm trying to calculate a pricing difference when there is a change requested by a customer. The units of measure are E for each, C for per hundred, M for per thousand. My formula is making either every result negative or positive, not taking into…
Justin
  • 15
  • 1
  • 5
0
votes
0 answers

Why is only the first line evaluated with IFS=' '

I'm trying to split a multi-line string on spaces only, preserving line breaks: IFS=' ' read a b c <<< "$(printf '%s\n' "foo" "bar" "baz")"; echo "a=[$a]"; echo "b=[$b]"; echo…
Rolf W.
  • 1,379
  • 1
  • 15
  • 25
0
votes
1 answer

jq: parse and display multiple values in JSON

I have this test.json file { "list": [ { "expand": "xx", "id": "xxxxx", "self": "https", "key": "test-11", "fields": { "field_1": "1234" } }, { "expand": "xx", "id": "xxxxx", …
att
  • 41
  • 2
  • 8
0
votes
3 answers

Printing the IFS chars

I've noticed that to print the value of the $IFS variable in the shell I have to do something like: $ printf '%s\nYour IFS is: %q' 'Hello' "$IFS" Hello Your IFS is: $' \t\n' My question is why do I need to pass the IFS in that special way? For…
carl.hiass
  • 1,526
  • 1
  • 6
  • 26
0
votes
1 answer

Combining IF formulas

I have two IF formulas that I would like to combine - please see attached excel doc. If C2 = "Blue" =IF(E2="","",IF(((((((B2*(C2-2))*1.02)/(E2-1))/1.02)+(-B2))+(B2))/(B2)<0.65,"NO BET",((C2-1)/(E2-F2)B2))) If C2 = "Green"…
alm
  • 13
  • 1
0
votes
0 answers

Reading with IFS=' ' , delimit one space but not multiple space

I am trying to read string into array using space as delimiter here I don't want to break down the spaces inside single quote or I can use double quote, if I use IFS='' (null), then all the words are getting read into first index but that's not…