Sunday, May 24, 2020

bash read file line-by-line



while read line || [ -n "$line" ]; do 
  line=$(echo $line | tr -d '\r')
  echo $line
done < inputfile.txt

# explain


# tr -- translate

cat file | tr -d '\r'    # delete new line

echo $companyname | tr ' ' '_'



Labels: , ,

Sunday, May 17, 2020

bash script counter increment

# TL;NR
$((counter + 1))


# Example - count lines of a file, similar to bash command "wc -l file.txt" :

num=0

while read f
do
  echo "$f"
  num=$((num + 1))
done < imput.txt

echo $num




Labels: , , , ,

Monday, May 04, 2020

git idea to merge 2 repo's into 1

Motivation:
Two repo's were created at different time for similar purposes and similar file names.  I want to combine them while keeping all commit history.   The problem is that the two share no common commit (i.e. commit hash).


Idea: 
Assign one commit as common, then add remote to repo 2 and rebase a repo2 branch onto the common node.


Labels: , ,