Search Results

Search: Posts Made By: metallica1973
Forum: Programming 06-06-2017
3,647
Posted By durden_tyler
Do not add a duplicate entry in the first place: ...
Do not add a duplicate entry in the first place:


tut_links = {}
for subdir, dirs, files in os.walk('./html/tutorials/blah'):
for tut in files:
if tut.endswith(".html"):
...
Forum: Programming 06-06-2017
3,647
Posted By durden_tyler
Is each value of the dictionary: (a) a list (or...
Is each value of the dictionary:
(a) a list (or array) of URLs? or
(b) a comma-delimited string of URLs?

If you want (a), then try something like the following:


tut_links = {}
for subdir,...
Forum: Programming 01-31-2016
3,916
Posted By durden_tyler
They are working just as expected. For a moment,...
They are working just as expected. For a moment, disregard the fact that your regex is a look-behind assertion.

The "search" method searches for the pattern and displays it. Since you have greedy...
Forum: Programming 10-21-2015
5,540
Posted By balajesuri
Its just more string processing. You don't need...
Its just more string processing. You don't need extra modules to do the job. Whatever code writes output in this form var=value , make it write as {"var","val"}
Forum: Programming 01-13-2015
3,396
Posted By jim mcnamara
Corona is correct - most command line utilities...
Corona is correct - most command line utilities are tuned and designed for a particular purpose, and really are very close to as good as it gets. Unless you are doing this to learn coding, or have...
Forum: Programming 01-13-2015
3,396
Posted By Corona688
Code which calls system() a lot, like this one,...
Code which calls system() a lot, like this one, are often exceptions to the rule. It uses C and shell instead of just shell :)
Forum: Programming 01-13-2015
3,396
Posted By Corona688
Also I am wondering, why do this in C? Shell...
Also I am wondering, why do this in C? Shell would be just as good for this.
Forum: Programming 01-13-2015
3,396
Posted By Corona688
What I am suggesting is 1) Download tmp_file...
What I am suggesting is

1) Download tmp_file
2) Open tmp_file in program
3) Unlink tmp_file (yes, while still open)
4) Search for line
5) Print results
6) Close file (which will now disappear...
Forum: Programming 01-13-2015
3,396
Posted By Corona688
fread(tmp_file, buflen, 1, filepointer); ...
fread(tmp_file, buflen, 1, filepointer);

Except, what do you mean by "queried"? And how will dumping it wholesale into memory help you? I suspect it won't. Usually you'd operate on lines...
Forum: Programming 12-19-2014
1,590
Posted By Corona688
Since arrays are not arbitrary-sized in C, you...
Since arrays are not arbitrary-sized in C, you would be wasting a lot of space.

Also, just dumping data into the array wouldn't make it line up with the array. You would still need to process the...
Forum: Programming 12-19-2014
1,590
Posted By Corona688
Speaking more generally, C does have a way to...
Speaking more generally, C does have a way to slurp an entire file into memory at once: mmap. It's actually better than reading it into memory, a 200MB file won't waste 200MB RAM just sitting...
Forum: Programming 12-19-2014
1,590
Posted By jim mcnamara
Corona corrected your problems. Consider a more...
Corona corrected your problems. Consider a more generalized approach.
This is not production code. It could use more error checking, for example. I use it for quick and dirty stuff.

It breaks a...
Forum: Programming 12-19-2014
1,590
Posted By Corona688
C does not change what variables do depending on...
C does not change what variables do depending on their type, or do anything for you when you ask it to convert one type to another. At best, it will ball it up and cram it through the mail slot,...
Forum: Red Hat 05-29-2014
3,340
Posted By Aia
test-nameserver.labtest.local is responding ;;...
test-nameserver.labtest.local is responding
;; Query time: 3040 msec
;; SERVER: 10.8.0.19#53(10.8.0.19)
;; WHEN: Thu May 29 11:56:11 2014
;; MSG SIZE rcvd: 98



dig will not add the domain...
Forum: Programming 10-24-2013
15,275
Posted By alister
Hi, wisecracker. From the python os.system...
Hi, wisecracker.

From the python os.system documentation:

On Unix, the return value is the exit status of the process encoded in the format specified for wait().

You should read the man...
Forum: Programming 10-24-2013
15,275
Posted By wisecracker
Be aware! Last login: Thu Oct 24 23:06:01 on...
Be aware!
Last login: Thu Oct 24 23:06:01 on ttys000
AMIGA:barrywalker~> python3.3
Python 3.3.2 (v3.3.2:d047928ae3f6, May 13 2013, 13:52:24)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin...
Forum: Programming 10-24-2013
15,275
Posted By Corona688
The return value of os.system("shell command");...
The return value of os.system("shell command"); is the return code of whatever was ran. You'd check for success by checking if it was zero.
Forum: Programming 10-24-2013
1,305
Posted By in2nix4life
Why go outside of Python to perform the file...
Why go outside of Python to perform the file search?


import os
import re

srchFile = 'GeoIP.dat'
srchDir = '/usr/share'

for root, dirs, files in os.walk(srchDir):
for file in files:...
1,315
Posted By ctsgnb
sed "/pattern/s/'[^']*'/'new text'/" infile ...
sed "/pattern/s/'[^']*'/'new text'/" infile

if a line contain the pattern then the substitution apply otherwise the line is just diplayed without substitution
Forum: Programming 01-04-2013
1,404
Posted By Corona688
scanf() has an unfortunate problem where, if it...
scanf() has an unfortunate problem where, if it finds any bad data in the stream, it puts it back. You are asking for %d, so it looks for digits. If it sees any non-digits, it will give up and not...
Forum: Programming 01-04-2013
1,404
Posted By jim mcnamara
#include <stdio.h> #include <stdlib.h> ...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int main()
{
char tmp[16]={0x0}; // read in strings it works better;
int num=0;
char *p;
...
1,917
Posted By Corona688
Please read: Useless Use of Cat Award...
Please read:

Useless Use of Cat Award (http://partmaps.org/era/unix/award.html)

grep string filename
is better than cat filename | grep string
1,917
Posted By Corona688
Useless Use of Cat Award...
Useless Use of Cat Award (http://partmaps.org/era/unix/award.html)

Searching the manual page of grep for color, I find the --color option. Usually it only prints color when printing directly to a...
1,005
Posted By elixir_sinari
awk -F: 'tolower($1) ~...
awk -F: 'tolower($1) ~ /testaccount2/{for(i=1;i<=NF;i++){if($i ~ /[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/) print $i}}' inputfile
3,827
Posted By Corona688
You need to have CAP_SYS_ADMIN privileges to...
You need to have CAP_SYS_ADMIN privileges to mount something, period, end of story, no exceptions.

The 'user' option in /etc/fstab works because /bin/mount is a setuid executable, always running...
Showing results 1 to 25 of 30

 
All times are GMT -4. The time now is 01:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy