Search Results

Search: Posts Made By: momo.reina
27,812
Posted By momo.reina
my solution (i added a for loop to print the...
my solution (i added a for loop to print the output text everytime the script is run, you can remove it if you don't need it.)

#!/usr/bin/python

import urllib.error, urllib.parse,...
Forum: Programming 05-06-2010
6,360
Posted By momo.reina
does this do what you want? ...
does this do what you want?

#!/usr/bin/python
import math

f = open('exams.txt','r')
total = []

while True :
try:
l = f.readline().split(None,10)
L =...
Forum: Programming 04-18-2010
1,518
Posted By momo.reina
python container =...
python

container = open('your_file_here').readlines() # load file info into variable container
container = [item[:3] for item in container] # remove trailing spaces or newlines
for item in...
1,642
Posted By momo.reina
to print the value of a set variable just use the...
to print the value of a set variable just use the variable name, no need to add the "$"

{print v
4,459
Posted By momo.reina
:b: i love these oneliners
:b: i love these oneliners
4,355
Posted By momo.reina
what exactly are you looking for? to know which...
what exactly are you looking for? to know which ones items match, or which ones don't?
8,280
Posted By momo.reina
look up awk and setting the delimiter (FS)
look up awk and setting the delimiter (FS)
3,900
Posted By momo.reina
while read line; do current=$(echo $line | awk...
while read line; do
current=$(echo $line | awk '{print $1}')
[ "$current" != "$check" ] && echo ""
echo $line
check=$current
done < your_file
2,128
Posted By momo.reina
so you want to exit if there are any errors? ...
so you want to exit if there are any errors?

see if what i wrote works, it will directly pipe STDERR to exit 1, so any errors that pop up should trigger it immediately
2,128
Posted By momo.reina
#fd 6 has the same target as STDOUT exec 6>&1 ...
#fd 6 has the same target as STDOUT
exec 6>&1
#STDERR is redirected to fd 1 (which means any errors go straight through to the pipe and trigger exit 1). if there are no errors, STDOUT is...
2,644
Posted By momo.reina
:b::b::b:
:b::b::b:
3,369
Posted By momo.reina
echo "(PROC_PROC_ID == 12183)" | sed...
echo "(PROC_PROC_ID == 12183)" | sed 's/\(PROC_PROC_ID ==\).*/\1 whatever you want here)/g'


mo@mo-laptop:~/scripts$ echo "(PROC_PROC_ID == 12183)" | sed 's/\(PROC_PROC_ID ==\).*/\1 whatever you...
2,367
Posted By momo.reina
this gets my vote. i must've been in zombie land...
this gets my vote. i must've been in zombie land when i used ${#line} (not enough coffee...)

i've also recoded the other piece of code to this, you can use whichever you prefer...

read pattern...
3,483
Posted By momo.reina
AFAIK, awk will not accept variables that need to...
AFAIK, awk will not accept variables that need to be expanded, which means that any pattern matching you want to do will have to be hard coded.

this solution doesn't use awk, giving you more...
2,462
Posted By momo.reina
you can also use grep's exit status $? to check...
you can also use grep's exit status $? to check if there is a pattern or not. if there is a pattern exit value is 0, otherwise 1.

mo@mo-laptop:~$ ls | grep scripts
scripts
mo@mo-laptop:~$ echo...
1,645
Posted By momo.reina
#!/bin/bash for line in $(cat file2); do ...
#!/bin/bash

for line in $(cat file2); do

echo $line | awk 'BEGIN { FS=";" ; OFS=";" } { print $1, $2, $3 }' >> file3

done

lin=1
for line in $(cat file1); do

pat="$(sed...
5,282
Posted By momo.reina
check the man pages for sort. then once the data...
check the man pages for sort. then once the data is sorted use sed to print out the first and last item.

here's an example using ls, i'll sort files by size then print the largest

...
18,981
Posted By momo.reina
page 102, bash beginner's guide, tldp.org
page 102, bash beginner's guide, tldp.org
2,159
Posted By momo.reina
tsk tsk i didn't read the problem :rolleyes:
tsk tsk i didn't read the problem :rolleyes:
2,159
Posted By momo.reina
sed doesn't work for you? sed 's/;/|/g' file
sed doesn't work for you?

sed 's/;/|/g' file
9,972
Posted By momo.reina
hey scrutinizer. yeah i just figured it out....
hey scrutinizer.

yeah i just figured it out. basically it takes input from the previous pipe, right?
14,182
Posted By momo.reina
awk should work as well: print "$isResult" |...
awk should work as well:

print "$isResult" | awk '{ print $1 $2 }' >> test.txt
3,415
Posted By momo.reina
bash: #!/bin/bash ...
bash:
#!/bin/bash

file=/home/mo/scripts/group.txt

for line in $(cat $file); do
if [[ $line == [0-9]* ]]; then
symbol=$line
else
echo "$line...
3,500
Posted By momo.reina
what's the pattern of the file? do you want to...
what's the pattern of the file? do you want to retain whatever comes after the numbers? will there always be numbers?

assuming there are always numbers in the output and you want to retain...
2,525
Posted By momo.reina
haha i was about to say the exact same thing. ...
haha i was about to say the exact same thing. it's been ages since i last saw a goto statement
Showing results 1 to 25 of 39

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