Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).
1
vote
1answer
11 views
Meaning of '2> >(command)' Redirection in Bash
A while ago I made a script and I added some logging around it, but I forgot how the redirection for the logging works :-(
The gist of it is:
#!/bin/bash
LOGFILE=/some/path/mylogfile
(
# here go ...
0
votes
1answer
10 views
Break out of while loop on error
I have a while loop in this form:
while :; do
performTask1 || break
performTask2 || break
performTask3 || break
...
performTaskX || break
done
Basically, I want to break out of the ...
1
vote
1answer
11 views
What does status_of_proc mean by bracket-points-bracket?
In an init.d script using a few /lib/lsb/init-functions, I got this line to report the status.
log_daemon_msg "Status" "$APPNAME" ; status_of_proc -p $PIDFILE $DAEMON && exit 0 || exit $?
...
1
vote
1answer
30 views
Extracting string up to first digit in Bash
I would like to find a straightforward method to extract the portion of a string up to where the first digit appears (possibly using regular expressions instead of traversing the string character by ...
0
votes
3answers
32 views
Integer expression expected in if statement
I have a small shutdown script, if the Mac runs over 24 hours it will shutdown. I'm not really experienced in bash scripts, but I did this:
!/bin/bash
#Maximum number of days to be up
max=1
#Get ...
0
votes
0answers
26 views
Why my script is not terminating after I exit the shell? [duplicate]
As far as I know if we are using & after a command or script, it will exit once the shell is terminated or logged out.
So I have a simple infinite loop script and I am executing it like ::
[root@...
3
votes
1answer
14 views
shell variable value in for loop different after loop
I have a challenge with a variable value changed in a for loop and the value of that variable after the for loop and using tee
SCRIPT_1:
STATUS=9
for SESSION in A B C
do
...
0
votes
1answer
26 views
Why does this echo call overwrite existing text?
Consider the following CSV file:
jdbc.driverClassName,oracle.jdbc.driver.OracleDriver
jdbc.username,kshitiz
It has to be transformed into:
-Djdbc.driverClassName=oracle.jdbc.driver....
0
votes
2answers
30 views
How to reformat the directories names?
I have many directories with the names as following
geom1 geom10 geom11 geom12 geom13 geom14 geom15 geom16 geom17 geom18 geom19 geom2 geom20 geom3 geom4 geom5 geom6 geom7 geom8 geom9
I would like to ...
1
vote
1answer
23 views
How to use inotifywait to watch a directory for creation of files of a specific extension
I have seen this answer.
You should consider using inotifywait, as an example:
inotifywait -m /path -e create -e moved_to |
while read path action file; do
echo "The file '$file' ...
0
votes
1answer
35 views
Terminology for Command in Command $( … )
I have a script update-wallpaper that goes somewhat this:
ln -s $(get-wallpaper-path) ~/.config/bg-manager/wallpaper
The experssion $( ... ) is called... something... and searching the symbols $() ...
2
votes
2answers
17 views
Read columns from file, then column into an exsisting csv file
Essentially, I have a csv file that contain multiple columns, called cols.csv
1,a,100
2,b,200
3,c,300
4,e,400
and I have a new csv file that has one column, called col.csv
f
g
h
i
I want to copy ...
2
votes
2answers
44 views
A script that is executed fine from file breaks when executed with Heredoc
I can run the following script just fine using the traditional way of:
cd ~ && vi script.sh [PASTE SCRIPT INSIDE] && chmod +x script.sh && ./script.sh && rm -rf script....
0
votes
2answers
31 views
Trying to figure out Linux script
I am a fairly new Linux user and I am trying to put a script together for a class.
The script is supposed to allow a user to type in a username, and it will say if the username exists or not. If it ...
2
votes
1answer
50 views
Script for network restart
Sometimes network completely fails on my server for samba shares (e.g. I could'n connect to server via ssh and samba shares were unavailable). Since there is no working solution to fix it (full ...
0
votes
0answers
43 views
Identify whether user is able to login with the given user ID and password
We have 300+ AIX servers.We have created local id for a user on all those servers.Now the user has to log in manually in all servers to check his whether credentials are working.So is there a way/...
1
vote
4answers
62 views
How to check if a variable entered is alphanumeric or not in ksh?
I am using ksh on AIX and I want to check if a variable, for example var1=sanySAN, var2=SANYsa%$3 is alphanumeric or not.
Here, var1 is alphanumeric and var2 is not. I know I can use [a-z][A-Z][0-9] ...
1
vote
2answers
59 views
How to convert row to column
Please help me to convert the row values into column.
My input file.dat is:
first two fields are alpha string and numbers respectively and input will always have same number of fields i.e., 6.
...
0
votes
0answers
31 views
Can't set chown from bash script [on hold]
I have a bash script like this one:
#!/bin/sh
chown root:www-data /etc/cron.d/file
chown root:www-data /etc/cron.d/anotherfile
But chown command isn't working. I know it's because of file ...
0
votes
2answers
23 views
Loop until grep does not find the text in a file
I have a file named file.txt. The content of the file is as follows
sunday
monday
tuesday
I wrote the below script and it loops just fine if the grep cannot find the pattern that was mentioned
...
4
votes
4answers
250 views
concatenate lines based on first char of next line
I am looking for away contact lines based on the next line. So far the only way I see is to create a shell script that will read line by line and will do something along these lines:
while read line
...
0
votes
2answers
26 views
How to convert seconds to hh:mm:ss format from output of another shell script
everyone
here is my script
/bin/wstalist | grep 'uptime'
Which is return value like "uptime": 3456, yes there's a , coming with output.
These number are seconds. I want to convert it to hh:mm:ss ...
0
votes
0answers
7 views
how to copy file form one server to another server which are created within 2 minutes [on hold]
i am beginner in shell script so please help me how to copy file form server which are create with in two minutes and i want to use corn job run every 2 minutes
copy those file which are create with ...
0
votes
1answer
53 views
Command works when copied and pasted but not in a bash script?
I'm trying to pass a windows command into a linux netcat shell and then read back the output.
So far I have:
cat <( printf 'ipconfig\n' )| nc -v 137.148.70.243 443
Which when copied and pasted ...
1
vote
2answers
40 views
Can “at” command execute any kind of shell script?
I created a java program that showed a message dialog. After pressing OK it is closed and the program execution ends.
Then I created a shell script alarm.sh that executed the program. I tested it and ...
3
votes
3answers
91 views
Checking a script is running [duplicate]
I have a job test.sh schedule to run every 5 mins, and another job test1.sh scheduled to run 12.30pm , @12.30 both jobs will run and is making a deadlock. So I need to check the job test.sh is running ...
2
votes
2answers
26 views
Multiple commands with quotations after SSHing
I have a server I have to ssh into with many commands which feature the use of variable assignment and consequently a lot of quotation marks. If we consider the script:
ssh user@host "kinit -k -t /...
0
votes
0answers
27 views
Get the multiple filename in linux [on hold]
I have filename like,
filename1.ZIP.zip,
filename2.ZIP.zip,
filename3.ZIP.zip
After double extracting I'm getting some filenames, that filename I want to read or store into variable. How to do?
...
-8
votes
0answers
47 views
How to get the every first file in a multiple folders copy into a single folder? [on hold]
I have a 250 sub-folders. How do I get the every first file in multiple folders copied into a single folder?
0
votes
1answer
12 views
Create a action in Sylpheed to decrypt messages
If you like to decrypt messages in the Sylpheed email client the manual suggest to create a custom action to execute the following command:
*gpg2 --no-tty --batch --yes --command-fd 0 --passphrase-fd ...
0
votes
1answer
37 views
Writing the output of a command to a file in a bash script
I am trying to write a simple bash script that executes the command tcprobe -i $1 where $1 is an mp4 file. Then, I want to write the output of this command, which should be a long string of ...
1
vote
1answer
34 views
Check the count of records from the source file and the loaded target
I have some source file suppose mydata.csv and my target table.I want to validate the record count whether it's same between the source file and the target table .The target table is in hive.
I have ...
3
votes
2answers
101 views
Store netcat output into variable
I want to store the output from an netcat function into a variable. I tried a lot of different ways, but it doesn't work to me. Can someone help me?
The whole scripting thing is whole new for me!
#! ...
1
vote
2answers
53 views
Is it possible to write to the crontab from a multipurpose script?
When I want to manipulate Unix cron I do $ crontab -e And then type (or paste) my directives.
You might now a way to paste directives to crontab -e directly from a script?
In other words: Instead ...
4
votes
1answer
44 views
How can a shell script avoid the SIGPIPE that would be caused by use of closed file descriptor?
A shell script can lose its standard and other file descriptors if the other end goes away. One way this can happen is by terminating a ssh client used to launch the script:
$ ssh localhost test
^C
...
0
votes
1answer
38 views
Sound indicator for when a script temporarily stops? For example, to fill in data or passwords? [duplicate]
I have a quite long Bash script I use to install Apache server environments including PHPmyadmin and several other utilities, after logging to the remote machine via SSH. I run the script via the ...
1
vote
1answer
35 views
Audio files altered by a bash command renaming them
Today I submit a case of an unexpected consequence of a shell command on some audio files that I do not understand at all.
Here are the facts:
My OS is ArchLinux, the windows manager is Awesome and ...
-3
votes
2answers
59 views
How to write bash script to open vi and edit document?
I'd like to write a bash script that essentially automates this process:
vi filename.pdf
(open "filename.pdf" using vi)
:4,7d
(in vi command mode, delete lines 4-7)
O
(in vi command mode, tap ...
-3
votes
0answers
19 views
how to reset user password my multiple unix or linux server. using shell scripts [closed]
here is the problem :- how can reset user password of my rehal 7 solries 10, 11
also i have to use to exception handling. how to log in the server. in staring for checking username is exist or not. ...
2
votes
1answer
42 views
Shell script is not working via cron job
I'm using a script which is working in Stand alone and is not working through the cron job .
qexma1@test:bin> head -n 10 test.sh
#!/bin/bash
declare -r PATH='/sbin:/bin:/usr/sbin:/usr/bin'
source $...
1
vote
2answers
46 views
Need to parse a csv file and it should store in variable
I need to parse a csv file and store the value in a variable. Below is the sample csv file
And below is the ./script.sh
#!/bin/bash
D="";
P="";
./xyz --project "$P" --displayname "$D"
For ...
-2
votes
0answers
45 views
How to get key value pair using awk? [on hold]
I have txt file with following value
f:0
c:Test C
s:test S
ctype:0
a:test A
t:10
r:test r
f:0
c:Test C1
s:test S1
ctype:1
a:test A1
t:10
r:test r
f:20
c:Test C
s:test S
ctype:2
a:test A1
t:0
r:test ...
-1
votes
2answers
28 views
How do I create a case statement for sorting files [closed]
I am brand new to bash and trying to understand how to best to build a script using mac OS for a problem that I am trying to solve.
I have a folder on my desktop named DIR1 which contains ...
-1
votes
1answer
27 views
Extract specific part from a file [closed]
My Input file is xyz.txt which contains bellow text:
mp ofile test._GDFS_Lookup.Lookup_ReRun "$AI_SERIAL_LOOKUP"'/rerun_lookup.dat'
mp ofile All_other_Setups.RPT_REQ_ID'file:'"$AI_SERIAL_LOOKUP"'/...
-1
votes
3answers
61 views
copy the data of a file multiple times into another file
Here I want to write some shell code and my question is, I want to copy one data file multiple times into another new file.
For example:
File1 contains 3000 lines of data. Now I want this data ...
0
votes
0answers
32 views
Why cd command is not working? [duplicate]
I wrote a basic script to mkdir and then cd to the directory. The directory is creating but cd is not working.
Details::
[root@a ~]# cat somefile
mkdir $1
cd $1
[root@a ~]#
Shell result::
[root@a ~...
1
vote
2answers
34 views
How to convert uA/mA to uA in each lines of csv file using c shell?
I have a *.csv file as bellow. What I want to do is converting all units to one unit (uA). Anyone can help to do this in c shell??
0
votes
1answer
40 views
searching for a pattern in only crontab scripts [closed]
In the server there are may scripts but few of them are only scheduled, that is they are in crontab.To find all the scripts in all directories I can use this, but i need to search only for cron ...
1
vote
0answers
33 views
.sh file in use by sftp after uploading and can't be executed
I'm using mobaxterm for ssh/ftp access. I first create a file test.sh. Then I edit the file and save it (it automatically uploads). Now I do
chmod 755 test.sh
and then try to run it with ./test.sh, ...
-1
votes
0answers
10 views
Monitor Several nfs performance [closed]
How do I start building this project? I am new to linux. What I have to do is like I have several nfs storage. then monitor all of then from client side. I need to check if client can access plus if ...