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

Logic is incorrect in the flow of loops and ifs

So I'm trying to find the lowest year in pat.txt and highest year in don.txt: Pat.txt Androf O kidney 24 2012 Blaren B kidney 35 2010 Cosmer A kidney 35 2000 Eralod O heart 53 2009 Forend B kidney 31 2003 Don.txt Zerk B kidney 20 2009 Rampe A…
-2
votes
1 answer

Python list comprehension- compare 3 lists

I am new to list comprehension. Currently I understand it when comparing two lists, but now that I am comparing 3, I'm a little confused. Basically I have this list: teams= ['subteamA', 'subteamB'] these 2 teams are compared to an csv file that…
Noriana
  • 17
  • 1
-2
votes
2 answers

reading a file line by line using the shell

the correct syntax to read a .txt file line by line is: while IFS= read -r line do echo "$line" done < input_file I don't understand why it works fine when we put
Ali Hamdy
  • 63
  • 4
-2
votes
1 answer

Split string with IFS using Bash?

I have a string like: Spain-South Africa:2-1 And I want to split it like: Spain-South Africa 2-1 I have tried to split it by IFS=':' but it gives me: Spain-South Africa 2-1 My code:
Man
  • 3
  • 2
-2
votes
1 answer

Search and copy a specific part of a file to another file in Shell Scripting

Suppose I have a text file with a lot of data. Using Shell Scripting, while reading the file if I get the keyword "CURRENT" it will copy the data to another file until it is getting the keyword "END-0". Not able to develop the script snippet for…
Sushovon
  • 21
  • 4
-2
votes
3 answers

Setting Shell Positional Parameters With "set ls -AF"

I am writing a ksh function (that is placed in the .profile file) that will present a menu of subdirectories and permit the user to choose one into which to cd. Here is the code: # Menu driven subdirectory descent. d(){ # Only one command line…
-3
votes
1 answer

What IFS actually is in bash?

The output of env does not contain IFS, so it isn't not an environment variable, so what it actually is? Is it just a global variable? IFS="C" bash -c 'echo X"$IFS"X' if it is an variale, why this line command not override it?
kingkong
  • 119
  • 8
-3
votes
1 answer

Why bash does not json split array with jq -r bash IFS explicitly defined variable

I am reading an array from a file file.json { "content": ["string with spaces", "another string with spaces", "yet another string with spaces"] } #!/bin/bash GROUP_ID_TEMP=( $(IFS=','; jq -r '.content' file.json) ) why does jq read content print…
mibbit
  • 4,997
  • 3
  • 26
  • 34
1 2 3
19
20