Since both of your scripts are comparing every element of the operand list to every element of the operand list, one might expect that there would be at least two cases where the operands would be identical. Those cases would be when you're comparing the first operand to the first operand (i.e., $HOME/Documents/ to $HOME/Documents/) and when you're comparing the second operand to the second operand (i.e., $HOME/Downloads/ to $HOME/Downloads/).
Maybe there is a logical mistake in both scripts???
What is the logic in both of your scripts behind the variable named counter? Why does it matter what the value of $counter is when trying to determine whether or not two command-line arguments are the same?
This User Gave Thanks to Don Cragun For This Post:
But, the code you've written in your shell scripts acts more like your C++ code with the inner loop changed from:
to:
There doesn't appear to be any attempt to keep from checking one element against itself in your command-line argument vector in either of your shell scripts.
I repeat: "What is the logic in both of your scripts behind the variable named counter? Why does it matter what the value of $counter is when trying to determine whether or not two command-line arguments are the same?"
But, the code you've written in your shell scripts acts more like your C++ code with the inner loop changed from:
to:
Yes you are right.
Quote:
There doesn't appear to be any attempt to keep from checking one element against itself in your command-line argument vector in either of your shell scripts.
I repeat: "What is the logic in both of your scripts behind the variable named counter? Why does it matter what the value of $counter is when trying to determine whether or not two command-line arguments are the same?"
When the shell script starts, both arg1 and arg2 have the same value.
So I use the counter with value 0, to determine this case, and advance the second for-loop to the next argument, and from there, I check if arg2=arg1.
If the second loop ends, the first loop progresses to the next argument.
The second loop restarts again with the first argument, and proceeds until it meets the first loop, where arg2=arg1 and counter -eq 0.
arg2 then proceeds to the next argument, until it ends, if no duplicate arguments found.
Then the first loop progresses to the next argument. etc.
The code that works, is the first I posted, and is this:
Good morning all,
This is the file name in question OD_Orders_2019-02-19.csv
I am trying to create a bash script to read into files with yesterdays date on the file name while retaining the rest of the files name. I would like for $y to equal, the name of the file with a formula output with... (2 Replies)
I have a .xml file that looks something like this :
<measInfo>
.........
string1
.........
</measInfo>
<measInfo>
......
string2
........
</measInfo>
I want to extract only the 'chunk of file' from '<measInfo>' to '</measInfo>' containing string1 (or a certain string that I... (13 Replies)
Hello ,
When using vim, can ctag and cscope support recording search results and displaying the history results ? Once I jump to one tag, I can use :tnext to jump to next tag, but how can I display the preview search result? (0 Replies)
Upon replacing my linux router/server with a Solaris one I've noticed very poor network performance. The server itself has no issues connecting to the net, but clients using the server as a router are getting a lot of IP fragments as indicated from some packet sniffing I conducted.
Here was my... (3 Replies)
For some reason ipfilter is blocking inbound fragmented ip packets (the packets are larger than the interface's MTU) that are encapsulating UDP segments. The connection works, so I know ipfilter is letting some traffic through, it is just a lot slower than it should be.
Rules that allow the... (3 Replies)
Discussion started by: ilikecows
3 Replies
7. Post Here to Contact Site Administrators and Moderators
Hi guys!
I was wondering what the outcome was of your survey of a few months ago? One of the questions was if people were willing to pay for additional services like an own account, like username@unix.com with mail box, etc.
Sorry if I missed the results if you had already posted them.
Ivo (1 Reply)
When discussing inodes and data blocks, I know Solaris creates these data blocks with a total size of 8192b, divided into eight 1024b "fragments." It stores data in "contiguous" fragments and solaris doesn't allow a file to use portions of two different fragments. If the file size permits, then the... (4 Replies)