The shell is unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks.
0
votes
2answers
871 views
How to call a kuu from a shell script
I want to kuu to an account which requires a password, but I want to do this inside a shell script. How can I provide the password from the shell script?
11
votes
5answers
6k views
Script to monitor folder for new files?
How do I detect new files in a folder with a bash script? I would like to process the files as soon as they are created in the folder. Is this possible to do so or do I have to schedule a script with ...
4
votes
4answers
1k views
“internet connection checker one-liner”
With this I can check, that there is "internet connection". if there is no "internet connection" (succesfull pings to this 2 places), then it waits 600 sec, then it runs along:
ping -W 1 -c 4 ...
16
votes
3answers
2k views
Clone ownership and permissions from another file?
Is there a command or flag to clone the user/group ownership and permissions on a file from another file? To make the perms and ownership exactly "like" that of another file?
1
vote
1answer
25 views
Different “history” command output after reconnecting via SSH
Why do I get different results for the "history" command for the same user after I reconnect a disconnected SSH session?
I connect to a server using putty (SSH), say as root
My network gets ...
13
votes
8answers
3k views
Object-oriented shell for *nix
Preface: I love bash and have no intention of starting any sort of argument or holy-war, and hopefully this is not an extremely naive question.
This question is somewhat related to this post on ...
9
votes
3answers
353 views
Why does “$(( ~33 ))” produce -34?
$ echo $(( 255 ))
255
$ echo $(( 33 ))
33
$ echo $(( ~33 ))
-34
$ echo $(( ~255 ))
-256
$
and my kernel is:
$ uname -a
Linux HOSTNAME 3.2.0-40-generic-pae #64-Ubuntu SMP Mon Mar 25 21:44:41 UTC ...
2
votes
3answers
51 views
Forcibly create directory hard link(s)?
I understand the reasoning why nearly every unix version doesn't allow hard-linking of directories (in fact HFS+ on OS X is the only one I know, but even that isn't made easy to do yourself). However, ...
15
votes
5answers
423 views
How to determine where an environment variable came from
I have a linux instance that I set up some time ago. When I fire it up and log in as root there are some environment variables that I set up but I can't remember or find where they came from. I've ...
21
votes
7answers
2k views
why does ls -d also list files, and where is it documented?
when specifying ls --directory a* it should list only directories starting with a*
BUT it lists files AND directories starting with a
Questions:
where might I find some documentation on this, ...
2
votes
3answers
458 views
Solarized colors in st (simple terminal)
I want to use st with solarized colors like I can with urxvt (of course this is done via .Xresources, in st the colors are defined in a header file). I've tried to put the colors in st's config file ...
2
votes
1answer
34 views
redirection to file issues with nohup and pipe
for the following script
ssh -t esolve@hostname 'sudo nohup bash -c "ls > log 2>&1 &"'
I always got error information:
nohup: ignoring input and appending output to ...
2
votes
2answers
42 views
how to initialize `/etc/group`?
After editing /etc/group, How this update starts functioning without restarting the system in Unix?
Is there any command we need to run?
3
votes
2answers
57 views
Wait for a X window to appear/disappear (in a sane way)
Inside a shell script, I need to wait for a window that has a string on its title to appear, do some action, and then wait for it to disappear, and do some other action.
Until yesterday, I had this ...
2
votes
1answer
60 views
File no longer available when trying to edit in vim via <()
When working with mercurial, I frequently do things like
vim <(hg cat -r 42 somefile)
However, if I try this with a file larger than several hundred lines, I get a Read Error in vim, and only ...
2
votes
1answer
73 views
What does “${x%% *}” mean in sh? [duplicate]
I just saw "$${x%% *}" in a makefile, which means "${x%% *}" in sh.
Why it is written in this way ?
how can a makefile detect whether a command is available in the local machine?
determine_sum = \
...
6
votes
2answers
120 views
Decode Flags for Kill Command
I am new to Shell Scripting.
I saw this Command on a Book for Linux shell Scripting
$ kill -HUP 1234 >killout.txt 2>killerr.txt
I know what the command does, but i am not able to understand ...
1
vote
2answers
57 views
How to make sure the shell builtin echo is invoked so that its not visible in process list?
Is this going to be visible in the process listing if the below line is executed from a command line or a shell script
bash -c "echo $password"
or
i just need to do echo $password from within ...
2
votes
1answer
35 views
process continous output of synclient
I am using synclient to track the position of finger on the touchpad.
I use the following command.
synclient -m 100 | awk '{print $2,$3}'
This command gives the 'x' and 'y' co-ordinate on the ...
4
votes
2answers
862 views
Selinux is denying access to mysqld
I have a script that dumps a mysql database. It then compresses the file and this gets stored in my home folder by using cron. The problem is I seem to be getting an error message.
mysqldump: ...
1
vote
2answers
83 views
shell script to do some text manipulation of text file data structure and slight content changes
Apologies in advance for the wall of text, not sure how else to represent the existing data structure.
I have been handed about a years worth of logs collected every hour from a server.
Sadly, ...
1
vote
1answer
56 views
Standard I/O File Descriptors
I am new to Shell SCripting
I code this
$ ls -l 1> stdout.txt
and I get the output as desired,
1> stdout.txt
redirects the output from standard output to the file stdout.txt.
I don't ...
2
votes
0answers
50 views
zsh: Echoing every statement?
I have an odd problem with zsh when I switch between shells in a particular way:
Option 1 (works well):
I start a zsh shell. I switch to tcsh with /bin/tcsh, and I switch back to zsh with /bin/zsh
...
16
votes
7answers
4k views
Batch renaming files
I have a directory full of images:
image0001.png
image0002.png
image0003.png
...
And I would like a one-liner to rename them to (say).
0001.png
0002.png
0003.png
...
How do I do this?
11
votes
2answers
882 views
Is there a way to intercept interprocess communication in Unix/Linux?
For intercepting/analyzing network traffic, we have a utility called Wireshark.
Do we have a similar utility for intercepting all the interprocess communication between any two processes in ...
1
vote
1answer
60 views
How to open process substituted file from php?
Here's what I tried to do myself:
$ type 1.sh
#!/bin/bash -eu
php -r 'var_dump(file_get_contents($_SERVER["argv"][1]));' -- <(echo 1)
$ ./1.sh
PHP Warning: file_get_contents(/dev/fd/63): failed ...
11
votes
1answer
1k views
The 'less' command-line equivalent of 'tail -f'
I would like to open up a file using less, and have it automatically scroll the file similar to tail -f.
I know that I can do less file, and then hit Shift-F to forward forever; like tail -f.
I want ...
11
votes
4answers
2k views
Unix equivalent of powershell?
I've always found it awkward when complex shell commands involve parsing text output with awk. Basically we're converting structured data into text, then parsing the text again to get back at the ...
2
votes
2answers
63 views
Including sub-parameters in help options to execute wisely without getopt or getopts?
I am writing a script which can choose a file and print specific content. For example,
san#./script.sh
Expected Usage : ./script.sh --file1 --dns
(Here it checks for file1, search for dns name and ...
0
votes
1answer
121 views
shell scripting escaping madness - sending single quotes to subshell
I'm beyond my skill level in getting this to work properly...
#!/bin/bash -x
# mxfbc.sh - mxf video file batch converter
# pass at the command line ...
# (1) the directory to batch convert (typically ...
1
vote
1answer
78 views
what's wrong with embedding php scripts inside bash ones?
I was trying to use php inside bash script, but I came across several problems. My first try failed with error about bash not being able to find end of here-document. The minimal version that still ...
0
votes
1answer
51 views
Can I redirect output to a log file and background a process at the same time?
Can I redirect output to a log file and background a process at the same time?
In other words, can I do something like this?
nohup java -jar myProgram.jar 2>$1 > output.log &
Or, is that ...
4
votes
1answer
41 views
Suspend and edit previous single line commands
Say I want to modify the latter of some concatenated command line options, is it possible without killing the first command?
Specifically I have compile and run scripts executed thusly:
> compile ...
1
vote
1answer
46 views
How to make ZSH tab completion work with two tabs
I saw a question like this on here, but the answer didn't work for me. I'm trying to set up tab completion and I want it that if I have two files fileA and fileB and I type fil<tab> it first ...
1
vote
1answer
238 views
Arch linux booting into rescue shell by default
I just installed Arch in my PC alongside windows 7 but for some reason it boots directly into the rescue shell, this is how it looks
It doesn't show any errors though, and if I press Ctrl+D it just ...
0
votes
2answers
1k views
Shell script to increment count of entries
I want a script which increments the count when the script runs. Basically I want to send an email notification when I find 10 devices down from the same country and scripts run after every down ...
3
votes
3answers
794 views
Split a file by line and have control over resulting files extension
There is a standard command for file splitting - split.
For example, if I want to split a words file in several chunks of 10000 lines, I can use:
split -dl 10000 words wrd
and it would generate ...
3
votes
2answers
5k views
Removing all spaces, tabs, newlines, etc from a variable?
This is the error I am getting and it's failing because of a variable whose value is supposed to be 2 (I am getting this using a select * from tabel).
I am getting spaces in that variable.
+ 0 !=
...
4
votes
1answer
47 views
Understanding when background process gets terminated
I have a script which starts a number of background processes and if works fine when called from the cmdline.
However the same script is also called during my xsession startup and additionally on ...
2
votes
3answers
305 views
Linux Shell Script - Send command over TCP to Sharp Aquos
I'm writing a shell script that needs to send an 8 character string terminated with a x0d to a Sharp Aquos TV. An example is 'POWR1 \x0d' (POWR1 followed by three spaces and LF)
The documentation ...
2
votes
4answers
100 views
Find directories that do not contain subdirectories
I'm writing script is ksh. Need to find all directory names directly under the current directory which contain only files, not subdirectories.
I know that I could use ls -alR and recursively parse ...
12
votes
4answers
515 views
difference between function foo() {} and foo() {}
I can define bash functions using or omitting the function keyword. Is there any difference?
#!/bin/bash
function foo() {
echo "foo"
}
bar() {
echo "bar"
}
foo
bar
Both calls to functions ...
0
votes
1answer
97 views
Deleting Non-empty Directory with smbclient
How can I remove a non-empty directory with smbclient?
I have tried the following:
1) rm
Result: NT_STATUS_NO_SUCH_FILE listing [dir_path]
2) recurse;rm
Result: No Error but also nothing happens! ...
11
votes
4answers
2k views
Usage of dash (-) in place of a filename
For a command, if using - as an argument in place of a file name will mean STDIN or STDOUT.
But in this example, it creates a file with the name -:
echo hello > -
How can I make - in this ...
9
votes
3answers
248 views
Which less popular shells do you use and what are their advantages?
Apart from what you can (arguably?) call the more popular shells (bash, csh, Korn, zsh) what other ones do you know and use and what unique features do they have?
ps - One answer per shell would be ...
0
votes
1answer
76 views
Moving Same files from different folders using shell script on AIX 5.4
There are two folders named Folder1 and Folder2.
Folder1 has files with name:For example
S-080001-0-0.xml with its corresponding same files in Folder2 named S-080001-0-0.xml
The change in Folder2 is ...
1
vote
1answer
295 views
Can I use pmap to find out Memory utilization?
I want to measure memory utilization of my Apache Server. Can I use the pmap command and pass all the process IDs of httpd and take that as total utilization?
pmap PID1 PID2 ....
It seems that pmap ...
3
votes
1answer
171 views
Use all system memory in Solaris
I am doing server testing and intentionally trying to crash a virtual Solaris server by using all memory. Server has a ulimit of 15 GB (several hundred GB of total system/swap memory). Is there a ...
0
votes
1answer
88 views
Multiple option arguments using getopts in bash
I am trying to process command line arguments using getopts in bash. One of the requirements is for the processing of an arbitrary number of option arguments (without the use of quotes).
1st example ...
2
votes
3answers
35 views
Can I reload variable in a watch command?
Part of my job involves some data handling. One of the tasks is to 'flatten' a set of directories (which we'll call Dir for now), and copy them to a new location called DirFlat.
This can take a long ...


