Hello everyone!!!! I am new to this forum ...I have a problem. And I thought that you are expert
so you can help me with that... I have a text file with maaany lines. Every line begins with something like that:
<http aksjfskcuhrf kushkfsnus> <http sxnfrksehfsd gsdg r> I don't know if every line has two http beacause the lines are too many but I know that every line has at least two. I would like to remove these https and leave every line with whatever has next. I just want to remove these https from every line.
Also, I would like to choose random 10 lines from the modified file (without the https) and write them in a file.
I would be the happiest person in the world if you could help me with these problems...
thank you in advance!!! 
something like
sed 's/<http[^>]*>//g' inputfile | tail +$(($RANDOM%$(wc -l <infile | xargs) )) | head >outputfile
omg!! thank tou very much for the quick answer!!!!
but I have a problem...
no, in each line, I have these:
< < mplamplampla...
---------- Post updated at 06:02 PM ---------- Previous update was at 06:01 PM ----------
I want to have only the: mplamplampla
---------- Post updated at 06:04 PM ---------- Previous update was at 06:02 PM ----------
hmmm I think that I fixed it!! :
I had forgotten the < !!!! 
Could you please provide an example of input you have,
as well as an example of output you expect ?
(ideally you can upload you file so people can make some test run with your real case and provide a more accurrate help to you.)
---------- Post updated at 01:06 AM ---------- Previous update was at 01:05 AM ----------
... ah ok lol
can i ask one more question??
after the last > my phrases begin after one space sotmething like this:
lalalalalala
I want to have
lalalalalala without a space in front of it
---------- Post updated at 06:08 PM ---------- Previous update was at 06:06 PM ----------
yeeesss I did it!!!
sed 's/<http[^>]*> //g' inputfile
I'm curious. Why pipe into xargs?
You want to remove whitespace at beginning of a line ?
sed 's/^ *//' inputfile >outputfile
You can gather it into one sed for example:
sed 's/<http[^>]*>//g;s/^ *//' inputfile >outputfile
---------- Post updated at 01:15 AM ---------- Previous update was at 01:10 AM ----------
@alister :
$ wc -l <myt
2
$ wc -l <myt | xargs
2
But i suppose if you point it out to me, it just means that my xargs is useless because the simple calculation and expansion will remove the leading tab anyway ...
---------- Post updated at 01:23 AM ---------- Previous update was at 01:15 AM ----------
by the way, my code contains an error of logic :
if a file contains n lines, my random stuff could bring a number which is n-1 or n-2 ... so there are only 1 or 2 ... lines to tail (so my code would need some enforcement to make sure we really get at least 10 lines).
I don't think it's removed, since everything that happens within arithmetic expansion is treated as if it's double-quoted. It's just that whitespace is allowed between operators and operands within $((...)).
Regards,
Alister
good night my friends!!! thank you sooo much for all you've done for me!!
I'll be here tomorrow again because I think that I will have another question!!! 
bye bye and thaaaanks!!!! 
---------- Post updated at 06:34 PM ---------- Previous update was at 06:31 PM ----------
good night my friends!!!
Thank you sooo much for all you've done for me!!!
I'll be here tomorrow again, because I think that I will have another question!!! 
bye byeee 
---------- Post updated at 06:34 PM ---------- Previous update was at 06:34 PM ----------
haha two times 
---------- Post updated at 06:36 PM ---------- Previous update was at 06:34 PM ----------
hahaha two times!! 
---------- Post updated 04-14-11 at 09:48 AM ---------- Previous update was 04-13-11 at 06:36 PM ----------
Hello again!!!
Can anyone tell me please what is the job of the command:
tr -cs "[:alpha:]" "[\n*]" < inputfile
I read sth on the web but I don't get it!
Contiguous non-alphabetic characters are replaced with a single newline.
oookaaaay!!!
now I have a different problem.I want to generate a number from 1 to 10 and I have written this:
x=$RANDOM
y=$RANDOM
num=`exp \($x32768+$y\) % 10`
and I have errors... 
---------- Post updated at 11:59 AM ---------- Previous update was at 11:57 AM ----------
num=`expr \($x*32768+$y\) % 10`
this is what I have written in reality ...
---------- Post updated at 12:01 PM ---------- Previous update was at 11:59 AM ----------
error:
expr: non-integer argument
What is your system? What is your shell? Unless you're stuck using a really old shell there's way better ways to handle numbers than expr.
expr is thorny. It expects each individual thing to be a seperate argument, like "1" "+" "2" . So (1+2)/stuff is out, that jams it all into one argument. So is "1+2" . 1 + 2 works because of the spaces.
expr has the % operator for remainder or modulus, 1 % 10 is 1, 9 % 10 is 9, 10 % 10 is 0, 11 % 10 is 1, etc. So you can do $RANDOM % 10 to get a number from 0-9, and add 1 to it to get a number from 1-10.
VAL=`expr $RANDOM % 10 + 1`
I use th bash shell... ok... if I want to generate a number for example from 1 to 100000, then why these commands:
x=$RANDOM
y=$RANDOM
num=`expr \($x * 32768 + $y\) % 100000
have the error:
expr: syntax error??
I think that I wrote them correctly... according to the colors...
Indeed. And the fact that many components of the expr(1) syntax are shell metacharacters compounds the hassles, since one can't simply stuff the entire expression within strong quotes.
Regards,
Alister
guys I found the problem... it wanted spaces all around 
thank you by the way for your support... I'll stay here 
---------- Post updated at 04:54 PM ---------- Previous update was at 01:08 PM ----------
hello again experts!!!
ANOTHER new problem
... I have a for loop and I fill a file inside it. But out of this for I have one more for loop. I want every time that I am out of the nested for to clear the file beacause I want to fill it again with new data.inside the nested loop, I have this: >> file so that I can store data serial. If I clear the file the next time I want to run this nested loop, this command >> file will write at the begin ?? Show me please how can I clear the file every time but remaining the file empty..... I have a big problem...... 
---------- Post updated at 05:04 PM ---------- Previous update was at 04:54 PM ----------
echo "" > file
would this be ok??
That will work, sort of. The "" is redundant. Just echo > file would serve the same function. The file won't be empty afterwards, just nearly so -- it'll contain one blank line.
To make the file completely empty without even a blank line in it, do : >file . : is a special built-in command that does nothing.
You could also simply delete the file. rm file
omg!!! thank you sooooooooooo sooooo much!!!! the command : >file is perfect!!!!!! 