Tagged Questions
2
votes
6answers
87 views
extract a file from jar file and get the diff
In real world I have a xsd in a jar file across various releases I am trying to check whether xsd has changed across releases 10.x.y.z to 11.a.b.c
I have different release directories which are read ...
1
vote
1answer
57 views
XML parsing using xmllint and customizing the output
I have xml file (say input.xml) of the following schema:
<?xml version="1.0"?>
<TagA>
<TagB>
<File Folder="FOLDER1M\1" File="R1.txt" />
</TagB>
...
1
vote
2answers
78 views
How to check in a shell script if an executable is running or not?
I have put an executable in a shell script file abc.sh. Now, I want to add one line in this abc.sh, to know whether it is running before my script starts or not and if yes, the kill that executable.
1
vote
1answer
100 views
How to create a password protected shell script [duplicate]
How can I create a password-protected shell script for read/write access. It should also be executable by all users without the password. I have sensitive information in the script.
0
votes
2answers
66 views
read file record by record and do transformation to the subsequent record based on above record and write into another file
Data file is fixed length file, and I want to read the file record by record and do transformations to the subsequent records based on the prior records (and write the results into another file).
...
1
vote
1answer
68 views
stop processing in shell script but don't exit
I've got a script that I run continually to monitor vsftpd logs. Here is a small example:
#!/bin/sh
tail -n0 -F /var/log/vsftpd.log | while read line; do
if echo "$line" | grep -q 'OK UPLOAD:'; ...
9
votes
4answers
623 views
Why doesn't “sudo su” in a shell script run the rest of the script as root?
A sample script can be as below:
#!/bin/bash
sudo su
ls /root
When using ./test.sh as the normal user, instead run ls as super user and exit, it switches to root; and when I logout, it executes ls ...
-6
votes
0answers
38 views
shell script to do it [closed]
Create a shell script named mtscript that does three things:
Displays the current month’s calendar.
Displays the current date and time.
Lists all files in your home directory (including hidden ...
3
votes
2answers
81 views
How to run "find -exec <script> {}\;
I have a script that changes the properties of the files for a folder.
Here is the example tree:
dir 1
--file 1
--file 2
--file 3
dir 2
--file 1
--file 2
dir 3
--file 1
...
5
votes
2answers
97 views
When is double-quoting necessary?
The old advice used to be to double-quote any expression involving a $VARIABLE, at least if one wanted it to be interpreted by the shell as one single item, otherwise, any spaces in the content of ...
0
votes
1answer
51 views
Why does my TCSH prompt change after cd?
My .cshrc file contains the following:
set prompt = "%{\033[0;32m%}%S%B\! <%~> :%b%s %{\033[0m%}"
Each time I cd out of my home directory, the prompt formatting resets to display:
33 ...
2
votes
2answers
78 views
Testing a string containing only spaces (tabs, or “ ”)?
My code below doesn't work:
stringZ=" "
if [[ "$stringZ" == ^[[:blank:]][[:blank:]]*$ ]];then
echo string is blank
else
echo string is not blank
fi
Result:
string is not blank # wrong
...
3
votes
1answer
75 views
How can I remove an element from an array completely?
unset array[0] removes the element but still if I do echo ${array[0]} I get a null value moreover there are other ways of doing this but if an element of an array contains spaces like below
...
3
votes
4answers
88 views
Replacing pattern after nth match is found on each line?
I have a file containing lines:
india;austria;japan;chile
china;US;nigeria;mexico;russia
I want to replace all the occurences of semicolon on each line with e.g. ;NEW;, but starting from the 2nd ...
2
votes
4answers
154 views
Using the not equal operator for string comparison
if [ "$PHONE_TYPE" != "NORTEL" ] || [ "$PHONE_TYPE" != "NEC" ] || [ "$PHONE_TYPE" != "CISCO" ]
then
echo "Phone type must be nortel,cisco or nec"
exit
fi
The above code did not work for me, so I ...