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
1
vote
1 answer

Why does pasting a Bash function cause "Display all possibilities" and a long list to appear?

The internal field separator (abbreviated IFS) refers to a variable which defines the character or characters used to separate a pattern into tokens for some operations. IFS typically includes the space, tab, and the newline. Show my current…
showkey
  • 482
  • 42
  • 140
  • 295
1
vote
1 answer

IFS Formula in Excel: Formula will categorize positive numbers but not negative numbers

I'm writing IFS Formula in Excel... I have positive and negative numbers that I'm grouping into categories. My formula works for positive numbers, but when it reads negative numbers, it results in a "0" answer. Question is - how can I get it to read…
Brandon
  • 13
  • 2
1
vote
2 answers

Get one of specific words from a text string. Excel 2016+

I have a list of words I need to get from a text string: A cow Dog-boy Hello-get it (just random words) I have multiple cells with random words surrounding desired ones: Random wordlsads A cow askjdhakj sla;alsj Dog-Boy l;sasla skla Hello-get it…
1
vote
1 answer

Complex Query using IF function in Google Sheets

I'm trying to create a dynamic dashboard. I've been able to create a query to filter for some of the information, but not all. What I'm trying to do is use the dashboard (the copy I shared is a slimmed-down version without charts) to select the…
1
vote
1 answer

Referencing a cell as the Value to use in an IFS statement in Google Sheets

I'm using an IFS statement to decide what a cell should use as a value dependant on what is entered into the cell. Which is fine, except that I have to hard code it into every cell that uses it as an equation. I need to have the Value1, Value2 etc…
Howard
  • 13
  • 2
1
vote
1 answer

Working formula broken after applying Arrayformula

Does anyone know why a working formula can be broken by Arrayformula? Below is the formula that is working. =IFS( AND(LEN(K:K)=0,LEN(O:O)=0,LEN(S:S)=0),"No Grade", AND(LEN(K:K)>1,LEN(O:O)=0,LEN(S:S)=0),"1…
1
vote
1 answer

Why does this IFS variable assignment not affect the cmd it precedes?

Consider this bash session: set -- 1 2 3 echo "$*" # 1 2 3 (as expected) IFS=a echo "$*" # 1 2 3 (why not "1a2a3"?) IFS=a; echo "$*" # 1a2a3a (as expected) Try it online! Why does the "assignment before command" syntax not work to…
Jonah
  • 15,806
  • 22
  • 87
  • 161
1
vote
0 answers

Using IFS with echo

Why does this: arr=(1 2 4 8 16) IFS=, echo "${arr[*]}" print out 1,2,4,8,16 (which is what I want) but this doesn't: arr=(1 2 4 8 16) IFS=, echo "${arr[*]}" ? I'd like to have a temporary IFS without having to set it then reset/unset it.
IpsRich
  • 797
  • 10
  • 23
1
vote
0 answers

Getting information from XML document and comparing it

I am trying to get information from an XML document and then taking that information and compare it to the information I am getting from a text document. But whenever I compare the number I receive from the XML to the number from the text document,…
DeltaP
  • 29
  • 5
1
vote
1 answer

How does IFS work in Bash?

#!/bin/bash # This question is from advanced bash scripting guide section 5.1 echo var="'(]\\{}\$\"" IFS='\' echo $var # output is '(] {}$" # \ converted to space. Why? echo "$var" # output is '(]\{}$" # special…
Ankur Agarwal
  • 23,692
  • 41
  • 137
  • 208
1
vote
2 answers

read: A specified flag is not valid for this command

I'm getting this error in a HP-UX machine + IFS=; /home/machine1/folder/borrado_de_logs.sh[45]: read: A specified flag is not valid for this command. And I'm using this code head -1 $rutatemporal/logfechas.log >…
1
vote
2 answers

IFS equal to newline character is not working in bash

I have a multiline string and I want to split is based on \n for which I'm setting IFS=$'\n' but it's not working, I've also tried IFS= and IFS=" " but no luck. Below is the sample code IFS=$'\n' read -ra arr <<< "line1\nline2\nline3" printf "%s\n"…
DDStackoverflow
  • 505
  • 1
  • 11
  • 26
1
vote
4 answers

IFS and command substitution

I am writing a shell script to read input csv files and run a java program accordingly. #!/usr/bin/ksh CSV_FILE=${1} myScript="/usr/bin/java -version" while read row do $myScript IFS=$"|" for column in $row do $myScript …
Mayavi
  • 35
  • 1
  • 4
1
vote
1 answer

IFS Report Designer - Register a new layout to the database

I am a student working for an IFS implementation project and currently learning how to use IFS Report Designer. However, I am stuck since my new layout is not shown in the drop down list when I try to print from Report Archive even though my new…
1
vote
2 answers

Read command is parsing multiline input

The read command in the below code is parsing only the first line from the input. But it works fine when the IFS is set to comma or any other symbol other than newline. u="* john dan" IFS=$'\n';read -ra q <<< "$u" for j in "${q[@]}" do echo…
Guna
  • 132
  • 2
  • 10