Search:
Type: Posts; User: ghostdog74
Search:
Search took 0.03 seconds.
-
if your purpose is really to just do a directory listing, i suggest you use modules that comes with Python instead. For doing a listing , use the os.listdir() method, or os.walk(). check the docs....
-
try this
ls -1 | xargs file
i leave you to do the counting part....
-
show a sample of how your email file looks like
-
awk -F"|" '{ one[NR] = $2; two[NR] = $3 }
END {
for (i = 1; i <= NR; i++) {
printf("%s|", one[i])
}
print ""
for (i = 1; i <= NR; i++) {
...
-
unless absolutely necessary, my advice, is to try to write "portable" code. for your example, the ls command is specific to the shell and is not found elsewhere, eg windows. If you are going to...
-
I had always thought to reference array elements you use $ instead of @?
eg $data[0] ?? well.correct me if i am wrong though.
-
sure, since you can use awk, here's an awk implemenation
awk '{ printf $1" "$2" "$1" "
for (i=3;i<=NF;i++){
printf $i" "
}
print ""
}' "file"
-
here's a vbscript for use in windows
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\temp\yourfile", 1)
Do Until objFile.AtEndOfStream
...
-
catting a file and piping to while loop is unnecessary because the while loop itself can take in redirection. it can be shortened to
while read line
do
....
done < $myvar
or just
-
well, the way you ask the questions, it is 99.99% homework to me..but nevertheless there's still 0.01% benefit of the doubt i can give to you.
USER=$1 #first argument
awk...
-
you can head down to the official doc site. there's a tutorial there by the creator himself, as well as the docs on its libraries and other stuff. that's all you need. Have fun
-
I know Perl long before Python for doing sysadmin tasks and general programming, but after knowing Python, I converted all my scripts to Python and looked back. Now i have an easier time maintaining...
-
assuming printable characters you want:
awk '/[[:print:]]/{print}' file > newfile
-
just a small note:
there is no need to do readlines() once a file handler is "initialized". This is sufficient
testFile = open(sys.argv[1], 'r')
for line in testFile:
#do something
....
...
-
OP is having problem doing that. so i just showed him another way that is commonly done.
-
do it step by step:
[/code]
# grep "$1" log
# if [ $? -eq 0] ; then
echo "found"
[/code]
-
I don't understand why you said it did not work. an example
# more file
This is first line
This is second line
This is the line with dollar sign and one : $1
this is the final line
Full...
-
though i will not do your homework, the part where you are not getting results i can suggest to you. you can try this (double quotes) :
grep "$1" logfile
-
solaris doesn't have GNU date (from previous post) or ls so you can't use those options. If you can't install any of these tools on your machine, AFAIK, the closest you can get is perl. in perl ...
-
if your top program has a -n option, you could try :
top -n 1
it shows the result 1 time.
-
some performance lag, as time is spent removing spaces etc..
pruneFile(){
......
line="$line${part//[[:space:]]/}" #Remove all whitespace.
...
-
well, most linux boxes nowadays comes with python/perl installed too..
-
you can use regular expressions with perl/python.sorry , not particularly fond with sed.
i added a few other words in your test file , just for testing.
at 11 range testingtesting
...
-
if you find that they don't provide this facility , then use another tool.
after all, there are plenty to choose from, esp in linux env :) . bottomline is, use the right tool for the problem to...
-
|
|