Deleting Extra Text Within A Line... (tearing Out Remaining Hair..!)

Hi all,
Im trying to tidy up a web scrape txt file so it just shows the URL's..
As below, I've got most with just the url but struggling to work out how to delete extra txt within a line, without deleting the whole line.
i.e a command that says.. delete from this word.. till end of line .. or delete everything between word1 and word2

//newzealandtrails.com/sites/all/themes/nztrails/css/print.css?nmkrag");
//newzealandtrails.com/sites/all/themes/nztrails/css/tabs.css?nmkrag");
//newzealandtrails.com/sites/default/files/ctools
//newzealandtrails.com/sites/default/files/New20Zealand%20Trails.png" //newzealandtrails.com/sites/default/files/nztrails-logo_0_0.png" alt="New Zealand Trails" /></a></div>
//newzealandtrails.com/welcome-new-zealand-trails" st_title="" class="st_sharethis_button" displayText="sharethis"></span>
//player.vimeo.com/video/71298207" webkitallowfullscreen="" width="500px"></iframe></div>
//w.sharethis.com/button/buttons.js"></script>

Thanks in advance


Similar Content



Rsync, Reliable "copy And Paste" Type Of Backup In Case Things Break?

What I did in windows was create images of my drive and restore them.

in linux I am running

Code:
rsync -aAXv --exclude={"/home/*","/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /* /path/to/backup/folder

and this creates a folder for me with all my files, and apparently saves meta data like permissions and paths...

Since I'm using arch and things break sometimes,I'm booted into a CLI with errors and cannot figure my way out since I'm a noob... would I be able to just delete my entire root and replace it with the rsync backup without a problem?

Ns2 Black Hole Attack Code Runing Problem

I installed ns2 using (sudo apt-get install ns2)
I hav code for black hole attack in aodv manet and while trying to run it on ns2 Im getting the fallowing error message
please tell me how to fix this..??

INITIALIZE THE LIST xListHead

(_o58 cmd line 1)
invoked from within
"_o58 cmd addr"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o58" line 2)
(SplitObject unknown line 2)
invoked from within
"_o58 addr"
("eval" body line 1)
invoked from within
"eval $node addr $args"
("default" arm line 2)
invoked from within
"switch -exact $routingAgent_ {
DSDV {
set ragent [$self create-dsdv-agent $node]
}
DSR {
$self at 0.0 "$node start-dsr"
}
AODV {
set ragent [$self cre..."
(procedure "_o3" line 14)
(Simulator create-wireless-node line 14)
invoked from within
"_o3 create-wireless-node"
("eval" body line 1)
invoked from within
"eval $self create-wireless-node $args"
(procedure "_o3" line 23)
(Simulator node line 23)
invoked from within
"$ns node"
invoked from within
"set node_(2) [$ns node]"
(file "atk3.tcl" line 55)

Extract Info And Find/count Strings From Blocks Inside Text File

Hello

I have a text file which has blocks like
Code:
dir1/dir2/dir3/name_run_number1:
line1_run_number1_part1
line2_run_number1_part2
line3_run_number1_part3...

Each block is separated with a blank line and there is the ":" in the "header" of each one while each block carries the same "number1" after "run_" suffix
What I want to do is for each block, extract the "number1" as shown in the first line and then for the lines below count from 1-20 and give a message if a "partX" line is missing. Any bash or python would be fine

Thanks

Mutt Does Not Show Full Subject

I use following shell script to send email. But the subject of email always shows "This" instead of "This is L_1.R is finished". You may refer http://www.linuxquestions.org/questions/linux-newbie-8/how-to-define-variable-in-%60ssh%60-4175540566/
Code:
host_list=("c15-0330-01.ad.mtu.edu" "c15-0330-02.ad.mtu.edu" "c15-0330-03.ad.mtu.edu" "c15-0330-04.ad.mtu.edu")
program=("L_1" "L_2" "L_3" "L_4")
subject="The job is finished"
ssh -f c15-0330-01.ad.mtu.edu 'echo' "the job ${program[0]} is finished" '|' 'mutt "zwang10@mtu.edu" -s' "This is "${program[0]}".R is finished";

Search For A Character In Specific Word In File And Replace It In The Word

Hi all ,
I have a requirement where I have a file. Contents of the file are :
#comments
VAR="abg"
RES=123
#comments
IC6790ABG="https://www.abc.com"
IC5678-vg="https://www.bhy.com"
IC-gy_567:78="https://www.gyt.com"
#comments
The variable names can not have characters like - , : so
in this file I have to find words starting with IC and replace characters like - ,:
I want to change only the variable name , not the whole line.
I have used SED command

sed -i '/^IC/s/[^0-9 a-z A-Z _]*//g' file

when I am using this command , it is replacing the whole line
output becomes :

#comments
VAR="abg"
RES=123
#comments
IC6790ABGhttpswwwabccom
IC5678vghttpswwwbhycom
ICgy56778httpswwwgytcom
#comments


But I want the output like this :

#comments
VAR="abg"
RES=123
#comments
IC6790ABG="https://www.abc.com"
IC5678vg="https://www.bhy.com"
ICgy_56778="https://www.gyt.com"
#comments

How can I get the desired output , thanks for your help in advance .

Python Ftplib

hello all,

please help me with python ftplib. i was trying to copy files from my linux machine to a windows server using ftplib. everything was working good. but i'm only able to copy files from the same directory the script is. how do i copy files from a different directory? i always get "file not found error message". here's my code :

Code:
tester_name = str (socket.gethostname())
def upload(ftp, file):
    ext = os.path.splitext(file)[1]
    if ext in (".txt", ".htm", ".html"):
        ftp.storlines("STOR " + file, open(file))
    else:
        ftp.storbinary("STOR " + file, open(file, "rb"), 1024)



parse_source_path = ('/path/to/where/i/go/')
parse_source_file_list = os.listdir(parse_source_path)

ftp = ftplib.FTP("server_IP")
ftp.login("username", "pass")

folder_list = []

ftp.dir(folder_list.append)

if str(tester_name) not in str(folder_list) :
    ftp.mkd("%s"%tester_name)
    ftp.cwd("%s"%tester_name)
    for files in parse_source_file_list :
        print files
        upload(ftp, files)


else :
    print "later"

Removing Multiple Lines From Cell Data In A .csv File

I am trying to process some .csv files with Linux as follows:

Some fields have data with newline characters embedded, like so:

"Bob Smith
531 Pennsylvania Avenue
Washington, DC"

(I verified the existence of the " via Wordpad. The file is too large to easily edit in Wordpad to get all the data for each row on a single line).

what linux command would I use on the files to get the data in each cell on one line?

I have tried:

1. awk -v RS="" '{gsub (/\n/,"")}1' file > newfile

but the cell data was still being read in as if "531 Pennsylvania Avenue" was a brand new row in the CSV file.

2. Command 1 followed by awk -v RS="" '{gsub (/\r/,"")}1' newfile > finalFile

but that resulted in all of the data in the file being put onto a single line.

3. awk -v RS="" '{gsub (/\r\n/,"")}1' file > newFile

But that result was the same as attempt number 2.

How can I preprocess the file so that:

"Bob Smith
531 Pennsylvania Avenue
Washington, DC"

is read as a single field on a single line as part of the row it should be associated with, like

"Bob Smith 531 Pennsylvania Avenue Washington, DC"

Need Help In Bash Scripting

I have two files which has exact same number of lines.
I want first line of first file should be filename of new file and content of this new file should be first line of second file.
Then second line of first file should be filename of again new file and content of this new file should be second line of second file.
then third line of first file should be filename of again new file and content of this new file should be third line of second file.
and so on...
I am trying to do it using for loop but I am not able to create two for loops.
This is what I have done
Code:
IFS=$'\n'
var=$(sed 's/\"http\(.*\)\/\(.*\).wav\"\,\".*/\2/g' 1797.csv) # filenames of all files
var2=$(sed 's/\"http\(.*\)\/\(.*\).wav\"\,\"\(.*\)\"$/\3/g' 1797.csv) # contents of all files
for j in $var;
do
#Here I do not know how to use $var2
done

Please help.

URGENT HELP!!! GPSR Patch With Ns-2.34 Ubuntu 12.04

Hey guys
I have been trying to patch GPSR with ns-2.34.The operating system i am using is ubuntu 12.04.
I have made all the necessary changes required in the various files .

I have another version of ns (ns-2.35 ) too but it is in a different directory.
Everytime I run my tcl file an error keeps coming up.
I will be greatful if somebody can help me.This is very very URGENT.


(_o29 cmd line 1)
invoked from within
"_o29 cmd if-queue _o23"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o29" line 2)
(SplitObject unknown line 2)
invoked from within
"$agent if-queue [$self set ifq_(0)] "
(procedure "_o17" line 28)
(Node/MobileNode add-target line 28)
invoked from within
"$self add-target $agent $port"
(procedure "_o17" line 15)
(Node attach line 15)
invoked from within
"$node attach $ragent [Node set rtagent_port_]"
(procedure "create-gpsr-routing-agent" line 29)
invoked from within
"create-gpsr-routing-agent $node $id"
(procedure "gpsr-create-mobile-node" line 41)
invoked from within
"gpsr-create-mobile-node $i"
("for" body line 2)
invoked from within
"for {set i 0} {$i < $opt(nn) } {incr i} {
gpsr-create-mobile-node $i
}"

How I Can Print A Specific Range Of Nubers Form A File.

hello,

i am trying to make a table from some files. i used this to record how much "RD_" field i have in my file. Quote:
grep -o 'RD_' $f|grep -c 'RD_'
forexample i got 5 "RD_" fields now i want to print 5 number of fields from another file starting from 2nd field. i did it mannully like Quote:
awk 'NR==1{print"{"$2","$3","$4","$5","$6","0.0000",""0.0000""}"","}' $file
i want to make it work together and a bit auto matic like PHP Code:
awk 'NR==1{print"{"$2"to "$5"," apend zeros to make it total 7 fields"}"","}' $file 


your coments would be apreciated
thanks alot