Reputation
2,428
Top tag
Next privilege 2,500 Rep.
Create tag synonyms
Badges
7 23 61
Impact
~501k people reached

1h
awarded  Popular Question
Aug
19
awarded  Nice Question
Aug
16
comment Prevent vendor change of packages
@Rinzwind: Is it a good idea to use zypper on Ubuntu?! I assume that they have packaged it for a reason, it just feels stange ...
Aug
16
comment Prevent vendor change of packages
@Oli: Yes, that is what I want to do :-).
Aug
13
asked Prevent vendor change of packages
Jul
10
awarded  Famous Question
May
29
awarded  Notable Question
May
26
awarded  Nice Answer
May
25
comment 14.04 - Laptop Battery Indicator does not show the right battery percentage
Did my answer help you? Could you please either give me a comment on my answer or accept it?
May
25
reviewed Reject I can't find my launcher
May
23
revised How to find manually installed packages?
Change quotes, write something about Ansible
May
9
accepted Upgrade to Kubuntu 15.04 broke settings and Akonadi
May
5
comment Access individual lines of a text file and create separate text file with that name
Could you please choose one of the answers as your accepted one?
May
4
comment Access individual lines of a text file and create separate text file with that name
The read() reads all the lines into memory. What one could improve is to use for item, content in zip(open(…), open(…)): since that only reads the lines as needed. This will then work with arbitrary file sizes since it only uses generator expressions.
May
4
comment Access individual lines of a text file and create separate text file with that name
Although I fear that you will end up with \n at the end of the files. Now that I think about it, either your filenames have \n in them, or you files lack \n at the end of the lines. This is not a problem since there is only one line in it, but I prefer my files to end with \n, so that cat *.txt gives reasonable output.
May
4
comment Access individual lines of a text file and create separate text file with that name
Sure, it will be taken care of. It's not like the computer would break because it ran out of file descriptors. I just like it a habit to not write any code that leaks anything . Your last version looks pretty golfed, but you could make it even shorter by using open(…).readlines(), see this Stack Overflow question ;-).
May
4
comment Access individual lines of a text file and create separate text file with that name
That does work with spaces in the files :-).
May
4
comment Access individual lines of a text file and create separate text file with that name
You could just use done < "$1" in the last line, no need to introduce another variable. The all capital letter variables are usually only used for environment variables (like PATH or EDITOR). When you write a shell script, you can just use lowercase variable names, like you did with count.
May
4
revised Access individual lines of a text file and create separate text file with that name
Format the advantages
May
4
comment Access individual lines of a text file and create separate text file with that name
Using null (\0) as a field delimiter be a bit less arbitrary, programs like find -print0 use this as a delimiter, and xargs -0 can read those. Since \0 is illegal for names in the filesystem, I think, this is fine for filenames. In a text file, you can have \0, I think, so that might break. Also you replace \n with your symbol. Couldn't you use that as a delimiter in awk directly? And if you have a file with DOS or Mac OS line breaks (\n\r and \r), it will not work. Your filenames are now just numbered instead of using the words in the second file. Did I miss something?