Debian Programming :: Sed Cannot Delete Forward Slash In While Loop?
Aug 14, 2014
I am downloading online videos with a bash script this is the code of script test.sh:
Code: Select all#!/bin/bash
while read line
do
"/usr/bin/wget" $line
sed -i "/$line/d" urls
done <urls
The while loop read the videos url from the urls file and parse them to the wget for dwonlaod, i write the wget for easy of exmple in this code otherwise i use another script to downlaod the embed videos , the code
Code: Select allsed -i "/$line/d" urls delete the url of videos from the urls file when it is download is complete.
The problem is http address contain the foreward slashes "/" and sed cannot delete them and get error, this is the urls file:
Code: Select allhttp://download.wavetlan.com/SVV/Media/HTTP/MP4/ConvertedFiles/Media-Convert/Unsupported/test7.mp4
http://download.wavetlan.com/SVV/Media/HTTP/H264/Talkinghead_Media/H264_test3_Talkingheadclipped_mp4_480x360.mp4
http://download.wavetlan.com/SVV/Media/HTTP/H264/Talkinghead_Media/H264_test4_Talkingheadclipped_mp4_480x320.mp4
http://download.wavetlan.com/SVV/Media/HTTP/H264/Other_Media/H264_test8_voiceclip_mp4_480x320.mp4
This is output of the test.sh:
Code: Select all# ./test.sh
http://download.wavetlan.com/SVV/Media/HTTP/MP4/ConvertedFiles/Media-Convert/Unsupported/test7.mp4
sed: -e expression #1, char 8: unknown command: `/'
http://download.wavetlan.com/SVV/Media/HTTP/H264/Talkinghead_Media/H264_test3_Talkingheadclipped_mp4_480x360.mp4
[Code] .....
View 3 Replies
ADVERTISEMENT
Nov 2, 2010
i want to replace
Code: <trus.analytics.platform.model.version>2.0.0-SNAPSHOT</trus.analytics.platform.model.version> with
Code: <trus.analytics.platform.model.version>2.0.0-b-20</trus.analytics.platform.model.version> using sed command. Code: sed -i
[Code]....
I think there is a problem with front-slash but not sure how to resolve it.
View 2 Replies
View Related
May 2, 2011
I am trying to use sed command to repalce one string with other but somehow replacement string contains forwards slash hence getting the error statement garbled!
[Code]...
View 4 Replies
View Related
Sep 26, 2015
I came to debian from fedora so there I used ( su - ) to become root user. So my question is that in debian, is it same using ( su ) and ( su - ) or here also using ( su - ) is preferred with slash or without slash. What is the correct and secure way in debian with full root status.
One more question relating gedit sources.list
I use as root account : gedit /etc/apt/sources.list (and then enter and sources file in gedit open)
Is this correct method or any other way as when save after changing entries inside it says error.
View 3 Replies
View Related
Feb 9, 2010
I have a directory that contains some files (over a 1,000) that have a '' in the filename. There are also some good files that I need to keep. therefore I need a script to delete based on inode.
What I have thus far:
list="$(ls -il /opt/PC/log/*RPOUT*.xml)" #this gives me the list
# I need to get the inode of.
for i in $list
do
find . -inum $i -exec rm -i {} ;
echo "delete file" $i >> /home/me/tmp/del_inode.txt
done
echo 'completed'
I know this is not right ... what I know is is the 'find' is. I need to loop through the $list gleaning inodes to get all the files with '' delete. I'm not sure how. The $i gives me the whole line. I just want the first position. set $() does not seem to work ...
View 5 Replies
View Related
Mar 31, 2011
I need to rename the resulted searched files from a loopI have the following code:
find . -name DOC* | while read i
do
find $i -type f -name '*.txt'
done
basically, I am searching for all txt files inside any folder starting with DOC name.this code is working fine with me.I need to rename those .txt files to .txtOLDOS: Ubuntu 10.4Bash shell
View 10 Replies
View Related
Dec 28, 2010
I am trying to include a QWebView widget in my application. Every time I try to compile it, I just get these errors:
Code:
$ LANG=en_US make
g++ -c -pipe -O2 -march=i486 -mtune=i686 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_GUI_LIB -
[code].....
View 1 Replies
View Related
Feb 9, 2011
i can not figure out why my program does not terminate if i type n when i read loop unless it is the last if statement in my program ?
while [ "$loop" = y ] ; do
echo "what does baket mean: " ; read word
if [ "$word" = why ]
[code]....
View 3 Replies
View Related
Oct 3, 2010
Here is my code
Code:
I just cant seem to understand loops. i havent put the loop in yet but what i would like is the user only to have 3 tries at guessing number then exit if wrong or it says "correct if right" tbh i dont even know if the above code is correct. i have tried several ways and position of the loops but each time is comes out wrong
View 7 Replies
View Related
Mar 25, 2011
I have a directory file capturing script, the variable is fine with in the loop but gone after the loop is done:
Code:
DIR="/usb/sdb1/media/music/"
i=1
[code]...
View 9 Replies
View Related
Apr 24, 2010
I am about to move my scripts to the next generation level, so I need some help I am stuck in varying my variable names in a loop. For example:
for user in ben dorothy mike pat
do
[ -r /home/$user ] && let "$user"check=1 || let "$user"check=0
[code]...
View 1 Replies
View Related
Jun 28, 2010
I am trying to do some shell programs. I tried some sites regarding the while loop, they give the structure as:
Code:
while [ n1 -lt 500 ]
do
echo $((n1+100))
done
But the below code also worked for me:
Code:
while ((n1 > 500))
do
echo $((n1+100))
done
By using (( )) I could use while, for. But the documentations didnt follow this way. I mainly use this for datastructure programming.
View 4 Replies
View Related
Aug 1, 2010
In the code segment below is a for loop I am having some considerable difficulty with. It just keeps iterating endlessly and totally ignores the 70 times limit specified. I can't ever remember having this problem before and am absolutely Clueless.
Code:
for ( x = 0; x < 70; x++ )
{
fputs ("CSN00", target);
fprintf (target, "%d", userid);
[Code].....
View 14 Replies
View Related
Nov 3, 2010
I've got a 'nested' for loop which has a grep in it, if the grep fails there's no output - however the error code is still $0 and the second for loop is still entered, there's also a grep in the second for loop.I guess ultimately what i need to know is whether there's a way of making grep generate an error code. when no results are found?
View 14 Replies
View Related
Apr 23, 2011
I want to loop through the records in the below file (homedir.temp)
/home/user1
/home/user2
/home/user3
I want to do the following activities with each record1. du -s - to get the total usage for that directory (my variable name is SIZE)2. divide SIZE by du -c for /home to get the percentage of usage. (my variable name is PER)3. write the directory, SIZE, PER to a filePROBLEMI am using the below for loop: for record in homedir.tempthe mentioned activitiesdonehe above is not looping through the records. It does the first record perfectly and exits the loop.
View 14 Replies
View Related
Apr 25, 2010
ITT and am just lurning about scripting and need to read a file and output the file to the screen. We need to do this with a while loop.
View 5 Replies
View Related
Jan 5, 2010
Edit: Oops. Sorry if this is in the wrong forum. I meant to post it in the general forums, yet somehow it ended up here. It kind of fits here as well I guess. I am currently trying to move my career forward and am not having much luck. So I've come to see if any of you can offer some fresh advice to help me out.
Let me tell you first where I stand in my career to give you an idea of where I'm starting from. I am currently 26 years old and have recently graduated with a bachelors of computer science from university. I would call myself an average student, nothing special, nor anything horrible. Out of university this landed me an ok job as a PHP developer. However I dont want to stagnate in this position scripting junk all day and not ever challenge myself. not to mention i could certainly rant for a while on the things that fall short at my current position (read: being banned from object oriented programming because the boss cant understand it)
I'd like to find a job that (1) challenges me just the right amount to help me learn and grow but not get overwhelmed in a language I enjoy (hopefully such as C/C++/Java or the like)
(2) is at a company with at least some software design process implemented (agile,xp,etc)and if that is to much to ask, then I'd at least like to move in that direction. So that is what I am looking towards and I would love any advice on how to achieve that. Maybe some of you were in my position 5 or 10 years ago and could shed some light on the subject. I've scoured the internet for job postings that offer what I am looking for, but they are really hard to find. The postings are usually looking for senior or intermediate level programmers with at least 5+ years of experience, or looking for web development script monkeys to make "The next big facebook app" (the job I already have)
I've also considered attending conferences and such, but have never really been, and wouldn't know what to do, or where to even find out about them (I used to see postings every now and then at university, but now I live in a small town.)
View 2 Replies
View Related
Mar 7, 2010
When I deal with an array in a function I con not access to the content of array in a for loop, but out of a for loop I can access to them! for example
[code]...
In a function when I send as parameter, in a for loop it prints the content of array and out of a for loop it prints the address of arr[i]
View 5 Replies
View Related
Nov 18, 2010
I'm writing a mass snmp toner check which polls any toners available to be snmp polled, however when using a loop statement I get the results on different lines; which sounds good, however the tool I use to check with (nagios) ignores the new lines.
Is there any way I can get the output on one line? Also, I need to raise a fault if any of the toners are below a specific level (with nagios you raise faults with the exit code) - any way I can do this without exiting the loop. Code below with bits and bobs commented out.
Code:
check_ink_levels ()
{
for ID in $INKS
do
[Code].....
View 10 Replies
View Related
Jun 1, 2010
#!/usr/bin/perl -w
use strict;
my @files = `ls -1`;
[code]...
View 2 Replies
View Related
Jun 29, 2011
I have a 50 file name NSSAVE0001.vtk to NSSAVE0050.vtk.Do I have to manually type individually command to open each file or can I have a loop to open file?
View 3 Replies
View Related
May 11, 2009
so far I have this
list = open('list.txt')
for x in list:
list.read(x)
View 3 Replies
View Related
Mar 1, 2010
I need to pass a large number of arguments to a function which takes variable number of arguments, such as gtk_list_store_new. But it doesn't look nice if i write something like gtk_list_store_new(NUM,TYPE_A,TYPE_B,TYPE_C,...,TYPE_OMEGA); because of large number of arguments. And, it will be a trouble to change number of columns because of need to manually change arguments to large number of such functions. So, how can i pass all the arguments to a function using a loop? Something like
Code:
for(i=0;i<NUM;i++)
{
push_arg(args[i]);
}
call_function(func);
?
Of course, i could just use asm code for this, but is there a portable way of doing so?
P.S. i mean C language.
View 2 Replies
View Related
May 26, 2011
I have images in jpg format
Code:
CIMG0100.jpg
...
...
CIMG0131.jpg
I used imagemagick to convert the files to gif with the following command
Code:
for i in {100..131}; do convert CIMG0$i.jpg CIMG0$i.gif; done # works
This worked like expected, but when afterwards I wanted to scale the images
Code:
for i in {100..131}; do convert -scale 25% CIMG00$i.gif CIMG00$i_scaled.gif; done # works not it seems the system is working for about half a minute, but I get no output. The single command
Code:
convert -scale 25% CIMG100.gif CIMG100_scaled.gif # works
works as expected and gives me a scaled image. What does the convert command do in the second case? is the for-loop wrong?
View 2 Replies
View Related
Aug 13, 2010
I'm learning c but then when i tried looping as i follow a tutorial, the numbers are wierd that it seems not right..
This is the example.
Quote:
When i run it, it outputs this.
Quote:
why?
View 2 Replies
View Related
Jul 9, 2010
I hade created a file with following text entries.
content of fileitems.txt
kdeaccessibility-4.4.92
kdeadmin-4.4.92
kdeartwork-4.4.92
kdebase-4.4.92
How do I read the file one line at a time and so its ready to do something with that line.
View 3 Replies
View Related
Apr 19, 2011
hint me why and how to execute the below for loop, the way i am trying to?
[bkcreddy17@local:~]$ cat -n test
1 date
2 ls -l
[code]...
View 14 Replies
View Related
Oct 10, 2010
my issue is that the when i put in the correct input its going into the loop like i put in incorrect input and wont break out of the loop even with the correct input entered
Code:
import java.util.*;
import javax.swing.*;
[code]...
View 3 Replies
View Related
Nov 25, 2010
I've got a loop which is able to echo out how complete a process is after each loop (e.g says 25% if the loop has 4 elements and has run once through). Is there any way I can print characters, perhaps a progress bar? I was thinking of using the percentage as a count or something and using.
Code:
I got told off for including code from work here.
View 14 Replies
View Related
Jun 7, 2010
The script that Iam trying to write is running a for loop and reading line by line from a text file. inside this for loop i would like to execute update SQL statement .
a pesudo code is
Quote:
`$ISQL -U $username -P $Password -D $Dbname -I $INTERFACE <<QRY
for id in $idlist #idlist iam reading from a file
[code]...
View 8 Replies
View Related