The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search a list of lines in file into files sriram003 UNIX for Advanced & Expert Users 2 05-20-2008 08:23 AM
deleting a varying amount of lines from a list of files benair Shell Programming and Scripting 4 04-14-2006 02:48 PM
extract lines with a given list of identifiers mskcc Shell Programming and Scripting 3 04-14-2006 12:15 AM
How will you list only the empty lines in a file (using grep) JosephGerard UNIX for Dummies Questions & Answers 1 07-21-2005 04:19 AM
list last few lines command zomboo UNIX for Dummies Questions & Answers 2 08-18-2004 02:34 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-28-2008
noratx noratx is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 30
[bash]Stripping lines from a list

Hello!

I have a script that is (among other things) doing the following:

Code:
list=/tmp/list1.txt
ncftpls -u <user> -p <password> -x "-l1" server.domain.tld > $list
cat $list | nl
echo "Choose file: "
read file
cat /tmp/list1.txt | nl | grep $file | sed -e "s/$file//g" -e "s/ //g" | column -t > /tmp/list2.txt
cat /tmp/list2.txt

With this, i want to choose a file that is located on a server and download it.
the sed lines was given to me on a guy on another forum who said it should do the trick. And it did, somewhat.
In the directory, i have around 40 files.
if i choose 1 - 9, it gives me a list with several lines like this


Code:
Choose file:
9
2 full_mysql_dump_2008-03-24_0:00.sql.gz full_mysql_dump_2008-03-25_06:00.sql.gz 10 full_mysql_dump_2008-03-25_0:00.sql.gz 18 full_mysql_dump_2008-03-26_0:00.sql.gz 1 full_mysql_dump_2008-03-26_12:00.sql.gz 2 full_mysql_dump_2008-03-28_06:00.sql.gz 30 full_mysql_dump_2008-03-28_0:00.sql.gz 35 full_mysql_dump_2008-03-2_00:00.sql.gz 3

but if i choose a higher number, it gives me this:

Code:
Choose file:
33
full_mysql_dump_2008-03-28_18:00.sql.gz

Just as i want it to do.

In this other script that i am working on, i am using the exact same thing, but this time with another directory on the same remote server, where it is only 2 files. (there will be more files there later).
The result is like the first example.
It doesn't cut away all the other lines that i don't want to have there.

Any of you guys who may know what is wrong, or maybe another solution for my problem?

Last edited by noratx; 03-28-2008 at 09:58 PM.. Reason: correcting typos
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0