I am trying to write a simple if statement but that driving me crazy with syntactical erorrs.
This is what I managed to come up
can one of you explain me
1. where to use spaces and where not to?
2. some time I see double square brackets used [[ ...]] when should I use these?
3.should there be a space between variable and value in condition like
<variable><space><operator><space><value>
4.when should i use either single/double quotes around variables and values?
5. should 'then' be used after every conditinal statement ?
The code above it still gives me error
I am using AIX and ksh. Not sure if it makes any difference
can one of you explain me
1. where to use spaces and where not to?
2. some time I see double square brackets used [[ ...]] when should I use these?
3.should there be a space between variable and value in condition like
<variable><space><operator><space><value>
4.when should i use either single/double quotes around variables and values?
5. should 'then' be used after every conditinal statement ?
Some very general answers: -
1) Use spaces as you show in question 3, not during assignments such as X=12.
2) I think there are two versions of ksh in general use, 88 and 93? [[ ]] is ksh 88 whereas [ ] is ksh 93 Most commercial UNIX environments still use 88 somewhat inexplicably. The company I work for is only 5 years old but uses 88!!
3) Yes for conditional statements.
4) Big subject. Quoting is one of the trickiest subjects in shell scripting. On a simple level if a string contains spaces you probably want to quote it but not always.
5) In 88 at least you want to put a "then" after an if although if statements are not the only types of conditional statements,
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Hi,
I hope this is the correct section in the forum to post as I'm trying to SSH from my MacBook.
I was looking to see whether ssh on my jailbroken iPhone 6s (10.3.1) still works fine and was following this old reddit guide. I installed OpenSSH&OpenSSL from Cydia and changed the password using... (7 Replies)
I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this:
$ look "string" "/home/patrick/filename.txt"
However, this gives me the following message:
"look: /home/patrick/filename.txt: File too large"
So, I have two... (14 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hi everyone,
I`ll try to be most clear I can explaining my help request.
I have 2 folders
Folder A-->This folder receives files through FTP constantly
Folder B-->The files from Folder A are unzipped and then processed in Folder B
Sometimes Folder A doesn`t contain all... (2 Replies)
hi, i'm a beginner in Linux, actually i use andLinux,
i have a data file with 11 columns
170 N SER T 25 56.962 42.701 -133.423 1.00 87.04 N
171 CA SER T 25 57.076 41.790 -132.280 1.00 86.65 C
172 C SER T 25 57.766 40.492 -132.692 1.00 87.52 C
173 O SER T 25 58.653 39.988 -131.992 1.00 86.59... (6 Replies)
Iam a learner of UNIX. Fortunately I got this site.
I want to check the file for its existance.
if
echo " Not present"
else
echo "Present"
fi
The above code is working fine. But I also want to check for the files which are compressed.
I tried the following code and it is not... (5 Replies)
I'm trying to grep a long ls by looking at the beginning of each filename for example:
Many files begin with yong_ho_free_2005...
Many files begin with yong_ho_2005...
I can't just use "grep yong_ho" otherwise It'll display both files.
So I'm trying to use a regex but my syntax is wrong.
... (2 Replies)
Hi,
We have a DEC Alpha 4100 Server with OSF1 Digital Unix 4.0.
Can any one tell me, if there are any commands on this Unix which are equivalent to "top" and "sar" on HP-UX or Sun Solaris ?
I am particularly interested in knowing the CPU Load, what process is running on which CPU, etc.
... (1 Reply)