Saturday, February 22, 2014

Bash: How to read file line by line

IFS=$'\n'

for line in $(cat file.txt)
do
       echo $line
done


OR

while read line
do
        echo $line
done < file

[While loop is the easiest method but it obliterates the formatting of lines including spaces and tabs.]


Thursday, February 20, 2014

Revert last submitted changelist from Perforce branch

Let's say Perforce trunk has changes c1,c2,c3. c3 is HOL. How do we revert the changes done through c3??


p4 sync @c2
p4 diff -se ...@c3 | p4 -x - edit
p4 sync @c3
p4 resolve -ay