LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-21-2003, 09:09 PM   #1
Ciccio
Member
 
Registered: Nov 2002
Location: Paraguay
Distribution: Mandrake 10
Posts: 573

Rep: Reputation: 30
some troubles with a script


well... basically i don't know how to write it... hehe... I mean.. I know how it should be... but it just doesn't write itself... if you know what I mean.

here is what it's supposed to do.

it takes only one argument, the name of a file.
it runs wc --line $1
it loops for each line counted by the previous command and it runs certain commands using for each line.
for practical uses, it prints the line.

here is what I have up to now...

lineas='wc --line $1'
i=0
while [ '$i<10' ]
do
('$i' ++ )
echo -n "linea "
echo -n $i
echo
done


Thanks a lot

 
Old 03-21-2003, 09:48 PM   #2
ranger_nemo
Senior Member
 
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
Code:
#!/bin/bash

# Save as command_name.sh
# and change permissions to allow execute

while read line ; do

# Insert commands to manipulate $line between here...



# ...and here

# If you still want to print the line, remove the ; from the line below
;echo $line

done
It's a simple way to do it, but should work. Run it as...

command_name.sh < file_name

It will stop at the end of the file, so there's no need to count lines. Each line in turn becomes $line, and can be used however you want.
 
Old 03-22-2003, 08:25 AM   #3
Ciccio
Member
 
Registered: Nov 2002
Location: Paraguay
Distribution: Mandrake 10
Posts: 573

Original Poster
Rep: Reputation: 30
hum.... interesting....
I'll try it today....

Thanks a lot...
 
Old 03-22-2003, 08:53 AM   #4
Ciccio
Member
 
Registered: Nov 2002
Location: Paraguay
Distribution: Mandrake 10
Posts: 573

Original Poster
Rep: Reputation: 30
worked like charms... eheheh... here is the final script:
Code:
##ignore these first three echoes... they are just the usage of the script.
echo "USO: siendo este un simple script, su uso es bastnatne siple:"
echo "lucas-download-full-cvs < <nombre de listado (el default es listado)>"
echo "cualquier duda consultar con alanbort@personal.net.py"

export CVSROOT=:pserver:<username>@cvs.hispalinux.es:/cvs/lucas
#here I set the CVSROOT variable but I think I could do a more complex sript that takes this as an argument...
while read line ; do

        # Insert commands to manipulate $line between here...
        cvs checkout $line

        
        # ...and here

        # If you still want to print the line, remove the ; from the line below
        ;echo $line "done"

done
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
troubles with SATA, troubles with NVIDIA aevangelica Linux - Hardware 6 10-17-2005 03:39 AM
cron bash script troubles zzyzx Slackware 3 04-12-2005 01:27 PM
Cron script troubles Galphar Linux - Newbie 1 01-19-2005 02:32 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 01:20 AM
Firewall Script Troubles ASP Linux - Security 3 09-23-2003 02:16 PM


All times are GMT -5. The time now is 12:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration