Please explain in English what you think the expression in the if statement in:
is doing. Since you can't get the else clause to work, by definition, your code is not working. How can you say your code is working when it won't run if the filename you pass to it is not a file that exists in the current directory? Furthermore, it is my belief that what the code above is doing is not doing what you think it is. Whether or not that means it is working when the named file does exist is open for discussion. I claim that if it is not doing what you think it is doing, it is not working. You claim that since the then clause of your if statement is working, everything is fine.
Never said the else clause was working, that's why I asked for a different way to script it.
First, the code will return an error, since the code you provided doesn't close the awk command nor does it provide it a file to look at.
But if those were present, and in English:
awk will first examine the file to see if it's present. Then it will evaluate the value of variable input to see if it is equal to the value of what a list (ls) command returns. ‘ls' will return every non hidden file in the directory it's run in, so strictly speaking, all the strings returned taken as a whole will not equal the value of input - but this is done in the context of an awk command with a specific file (the value of input) to look at, and if true (the file is present) it will print out the first field, followed by a tab, followed by the second field.
If, however, the value of input is not in the directory (the file isn't listed), then awk will exit with an error. That error is
where ‘a' is not a file in the directory. This is the reason why else is never executed - because the error is returned before the condition and commands that form part of the if statement are ever read.
p { margin-bottom: 0.1in; line-height: 115%; }
Quote:
Originally Posted by Don Cragun
Without running the following code, what output do you think it would produce:
After you have decided what output you think it should produce, run it and compare the output you get to the output you thought it should produce. Then go back and look at how I said that expression in the if statement would be evaluated in my comments in post #4 in this thread.
Please run the above test and let us know what happens!
it will return a prompt because you didn't close off the awk command before providing the file
with the awk command closed off,
Sorry, I had to run it to see what the code was doing . But you're changing the value of both $input and $(ls) so it's going to list the values of those as you specified.I don't see how this helps me with either of my questions in the original post.
p { margin-bottom: 0.1in; line-height: 115%; }
Quote:
Originally Posted by Don Cragun
As I said before, I can't test your code using the version of awk that I have available on my system because the code you're using is not technically correct (and produces a syntax error in the version of awk that I'm using, but runs without producing a syntax error in the version of awk that you're using). I can force the version of awk I'm using to get the results you're seeing by changing your code to:
I know that this is a relative question but can someone give me an idea of what would be considered a high number of context switches?
I am running vmstat and show a cs value of between 5000 and 6000 on a 4 processor system. How can I deduce if this number is high or not?
Also, the timeslice... (2 Replies)
there are several same servers(process) on more than one server(machine) providing the same service.
we store session/context within the server(process), if the same client login, he will be directed to the very server service for him last time.
But, if a server(machine or process) down, the... (1 Reply)
Hi,
There's a file with below contents which I have to read based on the input parameter provided by the user.
FILE_ID=1
FILE_FTP_ID=ftp.server1.com
FILE_FTP_USER=user1
FILE_FTP_PASS=pass1
FILE_ID=2
FILE_FTP_ID=ftp.server2.com
FILE_FTP_USER=user2
FILE_FTP_PASS=pass2
FILE_ID=3... (6 Replies)
Hello,
I have a file that I want to be able to split at specific positions. For example in the file below I want to be able to split at every occurence of 2 at the start of a line, into multiple files.
2 abc PQRST
abcRSTG
2 cde FGKL
abcLKGRG
ABCLKgrg
2 lmn OPT
lmopqrst
uvwxyz
... (1 Reply)
Hi all,
I've got this question that i need to solve:
"Type `vmstat -s; vmstat -n 1 5; vmstat -n 1 5; vmstat
-s` to your Ruby interpreter. Then terminate your Ruby session. Run the Unix com-
mand vmstat -s; vmstat -n 1 5; vmstat -s in the same terminal window you had
been using for Ruby. Did... (1 Reply)
Ive got multiple PCs, sharing an NFS mounted home dir. For certain apps I would like to keep the config files host specific. Easy solution is to create symlinks to local folders for configs. Ideally I would still want the .config files to reside in the user home folder.
Is it possible to... (2 Replies)
In a kernel based on 2.6.27:
In the schedule() routine they have a local variable switch_count:
/*
* schedule() is the main scheduler function.
*/
asmlinkage void __sched schedule(void)
{
struct task_struct *prev, *next;
unsigned long *switch_count;
struct rq... (2 Replies)
If suppose a middle level interrupt is being serviced and a high priority interrupts comes in then in that case what all process will take place.
The interrupt context switch will happen. But where will the interrupt context be saved?
Is there something called as part process data area? (4 Replies)
Hi
Just wondering ... do you have an example of context that would demonstrates how usefull the awk notation can efficiently be used ?
Thx :rolleyes: (6 Replies)