How to get following result using foreach command?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get following result using foreach command?
# 1  
Old 08-13-2014
How to get following result using foreach command?

Dear all,

For example, if data contains following numbers:
Code:
1 2 3 4 5 6

I would like get like below using foreach command,
Code:
1 2 
1 3
1 4 
1 5 
1 6

2 3
2 4 
2 5
2 6

3 4 
3 5
3 6

4 5
4 6

5 6


I would appreciate it a lot if anyone guides me how to get above result.

Ryan

Last edited by rbatte1; 08-14-2014 at 07:09 AM.. Reason: Added CODE tags
# 2  
Old 08-13-2014
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Linux find command seems to not transmit all the result to the '-exec command'

Hello. From a script, a command for a test is use : find /home/user_install -maxdepth 1 -type f -newer /tmp/000_skel_file_deb ! -newer /tmp/000_skel_file_end -name '.bashrc' -o -name '.profile' -o -name '.gtkrc-2.0' -o -name '.i18n' -o -name '.inputrc' Tha command... (3 Replies)
Discussion started by: jcdole
3 Replies

2. Shell Programming and Scripting

Grep command giving different result for different users for same command

Hello, I am running below command as root user #nodetool cfstats tests | grep "Memtable switch count" Memtable switch count: 12 Where as when I try to run same command as another user it gives different result. #su -l zabbix -s /bin/bash -c "nodetool cfstats tests | grep "Memtable switch... (10 Replies)
Discussion started by: Pushpraj
10 Replies

3. Shell Programming and Scripting

Grep result from dd command

Hi, I am running following command in a bash script for testing IO and use grep to get throughput number, but it did not work, it displayed everything: dd if=/dev/zero of=/dev/null bs=1G count=1 oflag=dsync | grep bytes | awk '{print $7}' 1+0 records in 1+0 records out 536870912 bytes... (2 Replies)
Discussion started by: hce
2 Replies

4. UNIX for Dummies Questions & Answers

tcsh: how to prevent a foreach from terminating a script when the result is null?

Sorry if this has been answered. I did search both Google and this site and did find this post: unix.com/unix-dummies-questions-answers/152992-how-ignore-errors-script.html However, it wasn't answered. I have the same question - how do you prevent a tcsh script from terminating when the... (4 Replies)
Discussion started by: deepstructure
4 Replies

5. Shell Programming and Scripting

How to use the result from a command in SED

Hi all, this is my first post so go gentle. My goal is to use SED to add data to the end of lines in a file, then send the results to standard output. However, I want to add the result of another command to the end of the lines. Basically: sed 's/$/ insert command stuff here/' file.txtHere... (1 Reply)
Discussion started by: jsmith_4242
1 Replies

6. Shell Programming and Scripting

Command result to file

I would like to send results as log to a file on unix. When I try to run following command, no command_result file occured. I can't see logs. How can I put the results to a file with java command on unix ? java -classpath . HelloWorld $parameter>command_result (2 Replies)
Discussion started by: senem
2 Replies

7. UNIX for Dummies Questions & Answers

echo command result

hello how can i print to screen the result of this command ? echo "pwd | sed 's/.*foo//'" when i type it im geting it printed as string "pwd | sed 's/.*DevEnv//'" and not the result of the operetion. tnx (2 Replies)
Discussion started by: umen
2 Replies

8. IP Networking

FTP command result

Hi there! I've used the ftp command to transfert datas between two linux box. The answer of this command, was: It strange because the transfert was complete and it brings two messages, the first is successful from PORT command and the second is an error from EPRT command! So, It seems that... (1 Reply)
Discussion started by: nymus7
1 Replies

9. Shell Programming and Scripting

How to define two variable in foreach command??

Hello, I just want to know how If it's possiple to define 2 variable using foreach command ??? I have directory inside that directory around 1000 file, I want to rename all of this files to something I have it in a list. Example :- ------This is what in my directory---------- d1 d2... (14 Replies)
Discussion started by: geoquest
14 Replies

10. UNIX for Dummies Questions & Answers

foreach command ?!

SaLAam What is the best way to change a word withing a files name. I know I'm not clear enough I will give example : - I have in /test/test N number of files like this 1662_WAITING 1666_WAITING 1670_DONE 1678_DONE 1663_WAITING 1667_WAITING 1673_WAITING ... (5 Replies)
Discussion started by: geoquest
5 Replies
Login or Register to Ask a Question