Search Results

Search: Posts Made By: momo.reina
28,274
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,708
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,757
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,734
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,608
Posted By momo.reina
:b: i love these oneliners
:b: i love these oneliners
4,709
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,758
Posted By momo.reina
look up awk and setting the delimiter (FS)
look up awk and setting the delimiter (FS)
4,384
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,382
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,382
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,917
Posted By momo.reina
:b::b::b:
:b::b::b:
3,790
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,585
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,804
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,681
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,757
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,925
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

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

sed 's/;/|/g' file
10,154
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,827
Posted By momo.reina
awk should work as well: print "$isResult" |...
awk should work as well:

print "$isResult" | awk '{ print $1 $2 }' >> test.txt
4,258
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,827
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...
3,474
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 08:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy