processing tab-formated output of command w/bash


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting processing tab-formated output of command w/bash
# 1  
Old 05-23-2008
processing tab-formated output of command w/bash

I have a command that when ran it will have an output such as

string LongerString
string2 longerString2
More MoreStrings

seperated by tabs. The command lists domains and their accounts set up in my server admin software (interworx).

The end result will be that it will run rsync for each of the domain accounts.

For example.

rsync -a /home/account/domain/html {backupserver}:~/backup/domain/html

if i try something like
for domain in `/home/interworx/bin/listaccounts.pex`
do
echo $domain
done;

it just prints out each word on its own line.

i've tried different forms of
while read line;
do
echo "${line}"
done < script_command and it always returns something like

./test.sh: line 4: xxxxxo xxxxxxxxxx.com
lxxxxn xxxxxxx.net
unxxxxxxe xxxxx.net: No such file or directory




Any ideas ?
# 2  
Old 05-23-2008
Take a look at the rsync man page. Maybe you could simplify your life and use the following:
--files-from=FILE read list of source-file names from FILE

Just an idea. Not sure if it's exactly what you're looking for.
# 3  
Old 05-23-2008
well, to provide a more in depth example of what i was hoping to acheive:


The script would perform the following, in order...

# cd /home/interworx/bin/

# run listdomains.pex which returns domains set up on server.
# output from that tool is as follows
# lfguildn lf-guild.net
# domain2 domain2.com

$account = lfguildn
$domain = lf-guild.net

# start loop on each line from listdomains.pex

# run backup.pex which backs up domain information from host control panel on each domain.

# scp partial backup .tar.gz from /home/$account/$domain/iworkx-backup/*{$date}.tgz

#perform rsync of HTML data from web directory
#make backup.hostname:~/webdata/$account/html directory if not exist

#rsync -av /home/$account/$domain/html/ backup.user@backup.hostname:~/webdata/$account/html/

The end goal is to have a tool that can be used to back up any dedicated server that one has leased at Sagonet.com and uses the Interworx Control Panel.

The only thing i cant figure out is how to to loop, line by line, on the output of a command in bash scripting.

I could write this as a php tool (or perl), but i'd rather use straight bash to make it simple and fast.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How do I assign the output of a command to a variable within a loop in bash?

In the else of the main if condition . else set lnk = $(readlink -f <path> | cut -d '/' -f7) echo "$lnk" if ] When I run the above on command line , the execution seems to be fine and I get the desired output. But when I try to assign it to a variable within a loop... (12 Replies)
Discussion started by: sankasu
12 Replies

2. Shell Programming and Scripting

Use bash command on awk field and output the result

Hello, I want to run a field from an awk command through a command in bash. For example my input file is 1,2,3 20,30,40 60,70,80 I want tot run $2 thought the command date +%d/%m/%y -d"01/01/15 + $2 days -1 day" and get the output 1,02/01/15,3 20,30/01/15,40 60,11/03/15,80 ... (2 Replies)
Discussion started by: garethsays
2 Replies

3. Shell Programming and Scripting

[Solved] SED - Bash - Inserting multi Tab character in the command

Hello. I am using : sed -i -e '/§name_script§/a#'"${MY_TAB11}"'# \ #'"${MY_TAB1}"'The Standard way'"${MY_TAB7}"'# \ #'"${MY_TAB1}"'==============='"${MY_TAB7}"'# \ ' "$CUR_FILE" Is there a better way to define "MY_TAB7","MY_TAB11" in other way than : MY_TAB1=$'\t' MY_TAB2=${MY_TAB1}$'\t'... (2 Replies)
Discussion started by: jcdole
2 Replies

4. Shell Programming and Scripting

redirect time command output to file (cygwin bash)

I have set up a bash script to run a long list of things that I need to time. I would like to redirect the output of time to a file. I have set it up like, echo "Runtimes for servlet 4, 100K structures" > test_times.txt echo "" >> test_times.txt echo "runs where N=10" >> test_times.txt echo... (7 Replies)
Discussion started by: LMHmedchem
7 Replies

5. UNIX for Dummies Questions & Answers

How to use the join command to obtain tab delimited text files as an output?

How do you use the join command and obtain tab delimited text files as an output? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

6. UNIX for Dummies Questions & Answers

set output delimiter as tab in cut command

I can not make it work, it prints \t rather than introduce tabs. cut -d "," -f 4,8 Samples.csv --output-delimiter="\t" | sort > out Since I am running this command within a shell script, I tried manually inserting tab in this command, still does not work. I am using bash shell Suggestions... (8 Replies)
Discussion started by: analyst
8 Replies

7. Shell Programming and Scripting

In bash script, how to assign output of a command to a variable while keeping tabs?

Hi, wondering if it's been asked before but didn't find matches from google. Basically I have this line: myvar=$(echo -e "a\tb") Now somehow the '\t' from the echo output gets replaced with white space and then stored in $myvar. It creates a problem for me later to use tab as delimiter to do... (2 Replies)
Discussion started by: birddie
2 Replies

8. Shell Programming and Scripting

Bash: executing a command based on organized output

Just learning scripting. I need to remove duplicate managed printers using lpadmin. I have the following script (it's rough and probably a better way to do it) that returns the values as IP (column 1) Printer Name (column 2).command: lpstat -v | grep -E ... (6 Replies)
Discussion started by: Zookpr
6 Replies

9. Shell Programming and Scripting

Piping output from a command into bash script

Hi all. I am using procmail to deliver an email to a script I am developing. Procmail delivers the email to the script on standard input. I imagine this is the same as piping input from a command into the script. Hence I've been testing my script by running echo 'test' | sms-autosend-backup.sh ... (2 Replies)
Discussion started by: akindo
2 Replies

10. UNIX for Dummies Questions & Answers

How do i tell my bash shell script to test the output of a command against something

How do i tell my bash shell script to test the output of the command i'm using?? I want this script to look for lines not equal to 1 then let me know.. $ cat blah ; echo ---- ; cat blah.sh 1 fe 1 fi 1 fo 0 fum 1 blahda 1 blah 0 blahh 1 bla 1 bl 1 blahhh ---- #!/bin/bash while... (1 Reply)
Discussion started by: phpfreak
1 Replies
Login or Register to Ask a Question