I'm afraid I have to say that your script brims over with syntax and semantic, and maybe even design errors; not sure if and how to cope with all of them. But, your questions first:
Quote:
Originally Posted by bananasprite
... I have file.sh and input.dat in the current filepath.
Is file.sh an input file or the script itself? Is input.dat a file with just one number in it, or some (lengthy) text?
Quote:
That's a "Command substitution" which "allows the output of a command to replace the command name ..." (man bash) and to be assignedf to the x variable.
Quote:
That calls the afore defined function check with one argument, $n.
Quote:
The sense of that construct escapes me. It prints two files - fi.sh and l - to nirvana, and checks the exit code. Is that just a test for file existence?
Quote:
Not clear (see above), what file.sh would be. If it is your script, it'd crash with several syntax errors.
That's a "Command substitution" which "allows the output of a command to replace the command name ..." (man bash) and to be assignedf to the x variable.
To expand on what my colleague RudiC already said:
The command executed in this command substitution (and which' output will replace its name) is
By redirecting the input of the (sub-) shell it will simply make the shell read the file. Because this is all the shell instance will do it will simply replicate it to its stdandard output and finally, when the subshell is left, this output will be picked up by the assignment operation. So basically what it does is assign the variable x with the contents of the file input.dat.
I hope this helps.
Moderator's Comments:
On a side note: PLEASE create meaningful, concise titles for your threads. "Help with Script" would be true for absolutely every thread in a forum dealing with shell scripting, won't you think?. I changed your title to something more meaningful.
Hey Friends, its me again! :o
I was asked to create a script that would go into our backup directories and delete/purge anything in the directory after a certain amount of days, normally I would be able to write something up that goes to the directory finds it and deletes it.
cd... (12 Replies)
I had gone through..google search.....and unix user post.......where I found so many ways of accessing files..... suppose if I am having 4 files, each file is having 3 columns, and I want to use each field of each column, then how can I use it.. how can I create array for each file's each column,... (8 Replies)
Hi,
balajesuri and durden_tyler, I have found your perl script for the thread https://www.unix.com/shell-programming-scripting/176370-perl-script-help-me-extracting-string.html, but find it difficult to understand the syntax.
Could you or any forum members kindly shed some light on the logic... (3 Replies)
grep -E '^(++){5}5000' <file_name>
this command searches value 5000 in only 6th column from provided file where pipe ( | )is delimiter which separate columns... can some one plz explain me what '^(++){5}5000' actually does..? :confused: (1 Reply)
Could someone explain why Python 3.1 errors out below? Do I need an additional module that's not required in 3.2 perhaps? I need to use 3.1 as it's the version available on a server I am using.
Python 3.2.1rc1 (default, May 18 2011, 11:01:17)
on linux2
Type "help", "copyright", "credits"... (0 Replies)
Hi all,
I'm very new to UNIX. I have got a coding, where i dont understand the below part. Could someone please explain it in detail?
awk 'NR > 1; NR == 1 { S = $0 } END { print S }' $textfile.bak > $textfile
could someone explain what
awk 'NR > 1; NR == 1 { S = $0 } END { print S }'
... (1 Reply)
hi this is the output of showrev command from my sun blade 150 machine.
bash-3.00# showrev
Hostname: u15_9
Hostid: 83685284
Release: 5.10
Kernel architecture: sun4u
Application architecture: sparc
Hardware provider: Sun_Microsystems
Domain: sun.com
Kernel version: SunOS 5.10... (1 Reply)
Hello!
I want to read a file line by line and have each line in a variable. I have found the following code.
#!/bin/bash
exec 3< data
while read <&3
do echo "The number is $REPLY"
a.out "$REPLY"
done
exec 3>&-
I don't understand the use of exec and its arguments, though having read... (3 Replies)
Hi,
Could you please explain me the below statement -- phrase wise.
sed -e :a -e '$q;N;'$cnt',$D;ba' abc.txt > xyz.txt
if suppose $cnt contains value: 10
it copies last 9 lines of abc.txt to xyz.txt
why it is copying last 9 rather than 10.
and also what is ba and $D over there in... (4 Replies)
Perhaps it's me - maybe I'm dumb and am getting this working solution wrong...
I have a binary value 00000011 in $binVal and I want to print the result in denary, so in perl I did as the perldoc -f oct told me to do and added a 0b prefix as so:
$binVal = "0b" . $binVal;
then I wanted to... (5 Replies)