<commit_before>#!/usr/bin/env bash
# Prints the local network IP address for a staticly defined NIC or search for an IP address on all active NICs.

# TODO fix the mac part so it also can search for interfaces like the Linux one can.
if [ "$PLATFORM" == "mac" ]; then
	nic0="en0"
	nic1="en1"
    	# Get wired lan IP.
    	lan_ip=$(/sbin/ifconfig $nic0 2>/dev/null | grep 'inet ' | awk '{print $2}')
    	# If no wired lan, get wireless lan IP.
    	if [ -z "$lan_ip" ]; then
        	lan_ip=$(/sbin/ifconfig $nic1 2>/dev/null | grep 'inet ' | awk '{print $2}')
    	fi
else
	#nic=eth0		# Use this NIC.
	nic="USE_FIRST_FOUND"	# Find the first IP address on all active NICs.

	if [ "$nic" == "USE_FIRST_FOUND" ]; then
		all_nics=$(ifconfig | cut -d ' ' -f1)
		nics=(${all_nics[@]//lo/}) 	# Remove lo interface.

		for nic in ${nics[@]}; do
			lan_ip=$(ifconfig "$nic" |  grep -Po "(?<=inet addr:)[^ ]+")
			[ -n "$lan_ip" ] && break
		done
	else
		lan_ip=$(ifconfig "$nic" | grep -Po "(?<=inet addr:)[^ ]+")
	fi
fi

if [ -n "$lan_ip" ]; then

	#echo "Ⓛ ${lan_ip}"
	echo "ⓛ ${lan_ip}"
	exit 0
else
	exit 1
fi<commit_msg>Better way of getting LAN IP?<commit_after>#!/usr/bin/env bash
# Prints the local network IP address for a staticly defined NIC or search for an IP address on all active NICs.

# TODO fix the mac part so it also can search for interfaces like the Linux one can.
if [ "$PLATFORM" == "mac" ]; then
	nic0="en0"
	nic1="en1"
    	# Get wired lan IP.
    	lan_ip=$(/sbin/ifconfig $nic0 2>/dev/null | grep 'inet ' | awk '{print $2}')
    	# If no wired lan, get wireless lan IP.
    	if [ -z "$lan_ip" ]; then
        	lan_ip=$(/sbin/ifconfig $nic1 2>/dev/null | grep 'inet ' | awk '{print $2}')
    	fi
else
	#nic=eth0		# Use this NIC.
	nic="USE_FIRST_FOUND"	# Find the first IP address on all active NICs.

	if [ "$nic" == "USE_FIRST_FOUND" ]; then
		all_nics=$(ifconfig | cut -d ' ' -f1 | tr -d :)
		nics=(${all_nics[@]//lo/}) 	# Remove lo interface.

		for nic in ${nics[@]}; do
			#lan_ip=$(ifconfig "$nic" |  grep -Po "(?<=inet addr:)[^ ]+")
			lan_ip=$(ifconfig "$nic" | grep '\<inet\>' | sed -n '1p' | tr -s ' ' | cut -d ' ' -f3 | cut -d ':' -f2)
			[ -n "$lan_ip" ] && break
		done
	else
		lan_ip=$(ifconfig "$nic" | grep -Po "(?<=inet addr:)[^ ]+")
	fi
fi

if [ -n "$lan_ip" ]; then

	#echo "Ⓛ ${lan_ip}"
	echo "ⓛ ${lan_ip}"
	exit 0
else
	exit 1
fi
{'fraction_non_alphanumeric': 0.18243243243243243, 'fraction_numerical': 0.013091216216216216, 'mean_word_length': 2.9681742043551087, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4182420', 'n_tokens_mistral': 1016, 'n_tokens_neox': 950, 'n_words': 313}