Search Results

Search: Posts Made By: momo.reina
27,156
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,018
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,353
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,478
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,139
Posted By momo.reina
:b: i love these oneliners
:b: i love these oneliners
3,701
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?
6,005
Posted By momo.reina
look up awk and setting the delimiter (FS)
look up awk and setting the delimiter (FS)
3,491
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
1,924
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
1,924
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,221
Posted By momo.reina
:b::b::b:
:b::b::b:
2,645
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,074
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...
2,930
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,042
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,406
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...
4,603
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,276
Posted By momo.reina
page 102, bash beginner's guide, tldp.org
page 102, bash beginner's guide, tldp.org
1,767
Posted By momo.reina
tsk tsk i didn't read the problem :rolleyes:
tsk tsk i didn't read the problem :rolleyes:
1,767
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,800
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?
12,303
Posted By momo.reina
awk should work as well: print "$isResult" |...
awk should work as well:

print "$isResult" | awk '{ print $1 $2 }' >> test.txt
2,951
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,133
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,319
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

 

Featured Tech Videos

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