Recently I started working on Machine Learning project. So started working on large uncleaned data files to clean and learned one of this tip today.
To add line numbers to large file just run below command on the file.
cat -n file_name >new_file_name
Above command will add the line number at the start of each line from file_name separated by tab and store in new_file_name without effecting the content of the file file_name.
If you want to replace tab with any character like comma, pipe(|) etc. Run below command.
cat -n file_name | sed 's/\t/\,/g' >new_file_name
cat -n file_name | tr '\t' ',' >new_file_name
Some times Mac systems may not identify tab(\t). Press Cntrl + V and press tab to identify tab key in Mac.