The shell is unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks.

learn more… | top users | synonyms (1)

1
vote
2answers
398 views

how to add line in a /etc/sudoers file with the help of shell script (50servers)?

Anyone can help me with shell script, I want to know script which can edit /etc/sudoers file and let me add {{{{{userid ALL=(root) ALL}}}} to 50 server I have on same network?
2
votes
1answer
361 views

Xubuntu 12.04: slow login

I'm running Xubuntu 12.04, and after I ran the update, my login started slowing down big time. I've dabbled a little bit with the programs in Settings -> Settings Manager -> Session and Startup, and ...
3
votes
3answers
124 views

how do I do this: dd if=coolstuff.iso of=(ssh kev@mypi )

the card reader on my laptop doesn't want to work. can I use dd (or some other tool) to write an image to a networked disk. I am trying to replace one raspberry pi distro with another. The SD card ...
1
vote
1answer
44 views

how to check if mysql table is used or an application accesses the table in shell script?

A shell script is doing dump for a mysql table, but before dumping the table I want to check if this table is used by any other application. If so, I want to wait and enter in a loop until the ...
2
votes
3answers
75 views

Count result in a find/exec statement

I have some Perl files which I have to modify through a simple sed call. Basically, I have to remove the first line of all of them. Currently, I managed to do this : find <PATH> -type f -name ...
2
votes
2answers
31 views

git diff - listen for key press

I want to run the following commands: git diff git commit git commit will open the default editor to edit the commit message. But if the difference if not too long it will close immediately. How ...
11
votes
2answers
2k views

recursive statistics on file types in directory?

I did a website scrape for a conversion project. I'd like to do some statistics on the types of files in there -- for instance, 400 .html files, 100 .gif, etc. What's an easy way to do this? It has to ...
0
votes
1answer
33 views

Commands inside bash not being interpreted?

I'm trying to execute a command inside a bash script, $(pwd) is not being interpreted at all, and not even using eval. This do not work: cat apache-vhost.conf | sed 's/{path}/$(pwd)/g' Neither ...
1
vote
3answers
38 views

How to output comma-separated strings using bash brace expansion

I'd like $ echo a{b,c,d} to output a comma-separated list like ab,ac,ad instead of the usual output ab ac ad What's the easiest way to do that on the command line?
2
votes
1answer
49 views

Where can I find a good boilerplate bashrc?

I've used unix/linux at work in the past, and recently started developing on a Mac. I'd always (lovingly) borrow co-workers' bashrc's for a good starting point, such as common aliasing and commands, ...
5
votes
4answers
2k views

Convert seconds to well format date

I want to display /proc/uptime in well format as: DD:HH:MM:SS /proc/uptime give me up time of system in seconds, is there a standard solution that convert seconds to this format?
0
votes
2answers
54 views

why is ! character used in shell scripts [duplicate]

I recently encountered a situation where I tried to use ! as a record separator for my string array in shell script. When I used it in my shell script, the script got expanded automatically. An ...
11
votes
4answers
1k views

How Does Linux deal with shell scripts?

For this question, let's consider a bash shell script, though this question must be applicable to all types of shell script. When someone executes a shell script, does Linux load all the script at ...
-2
votes
1answer
59 views

concatenate or remove multiple files of a directory

In general for file concatenation with the same extension, we use cat *.txt. But in case we are in a different directory and trying to concatenate another directory's files how to do that ? I have ...
2
votes
3answers
45 views

A shell tool to “tablify” input data containing ANSI escape codes

I have input containing ANSI color codes that I'd like to tablify. I want the output to remain colored, so the tablified output should maintain the ANSI color codes. Hence, naively stripping them away ...
7
votes
2answers
384 views

How do I add network or user source connection data to history entries?

I would like to modify the history settings for all users on the systems that I manage. I would like it to contain the information from the connecting terminal like from who sysadmin:/ # who sysadmin ...
4
votes
4answers
1k 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: ...
4
votes
2answers
227 views

Merge fields in a file

I have a file with 7 columns, a GFF file having chromosomal regions.I want to collapse the rows where REGION ="exon" to only one row in the file.The row has to be collapsed on the basis of regions ...
2
votes
3answers
145 views

Simplified navigation in terminal

I know IDEs are the wave of the future, but I always find myself coding in vim in a Linux terminal. Old dog. New tricks. Anyway, navigation becomes challenging when dealing with long package names. ...
25
votes
6answers
42k views

How to overwrite target files with mv?

I have a ton of files and dirs in a subdirectory I want to move to the parent directory. There are already some files and dirs in the target directory which need to be overwritten. Files that are only ...
1
vote
1answer
54 views

Why does redirection in crontab result in a zero byte file?

System: Xubuntu 13.10 When I have this crontab entry */5 * * * * cat /home/dbk/.bash_aliases &> /home/dbk/Desktop/junk junk has a byte size of 0. Running $ cat /home/dbk/.bash_aliases ...
1
vote
0answers
25 views

How to automatically launch a lxc container on ssh connection?

I'm attempting to setup a system that automatically creates a new sandbox on a ssh login to use as a temporary jump box into my server. So to do this I was wonder how to setup lxc to spin up a new ...
0
votes
1answer
262 views

Why alias does not work in AIX (korn shell, .profile)?

I have these files in my home directory: drwxr-xr-x 3 meuser staff 256 Oct 12 13:11 . drwxr-xr-x 102 bin bin 4096 Sep 30 12:28 .. -rw------- 1 meuser staff ...
4
votes
6answers
130 views

List all binaries from $PATH

Is there one-liner that will list all executables from $PATH in bash.
2
votes
3answers
150 views

How to use rsync or scp to efficiently copy the files from machineB and machineC to machineA?

I am running my shell script on machineA which copies the files from machineB and machineC to machineA. If the file is not there in machineB, then it should be there in machineC for sure. So I will ...
2
votes
2answers
28 views

Setting tabstop for bash output

Is it possible to set a tabstop (number of spaces per tab) for the more and less commands? In vi, I've added this line to .vimrc set tabstop=4 However when I read through a file with more it still ...
4
votes
2answers
92 views

Find command returns wrong files

I'm trying to find files in a folder using find command which are a day older than the day on which the command is run.. I use the following command: FILES_dcn=($(find $dir_dcn -maxdepth 1 -type f ...
1
vote
1answer
56 views

Not able to copy multiple files using rsync 3.0.9 version?

I am trying to copy two files using rsync from a machineB but somehow it always copies only one file but not the second file - Here is the syntax I am using - rsync -avz ...
4
votes
4answers
165 views

Pass shell variable as a /pattern/ to awk

Having the following in one of my shell functions: function _process () { awk -v l="$line" ' BEGIN {p=0} /'"$1"'/ {p=1} END{ if(p) print l >> "outfile.txt" } ' } , so when called as ...
1
vote
1answer
576 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 ...
9
votes
2answers
688 views

Command line prediction

I've found an interesting paper: Predicting UNIX Command Lines about command-line prediction (based on user past activity), and I wonder if any actual implementation of such thing exists?
2
votes
1answer
63 views

How to detect global key presses

I have an Asus laptop that has a special key that can be configured to launch any software (at least on Windows). The general question is: how can I detect any key press (globally)? Then, how ...
3
votes
1answer
86 views

What does exec 3<&1 do?

I understand exec can do I/O Redirection on current shell level. but I only sees usage like exec 6<&0 # Link file descriptor #6 with stdin. # Saves stdin. exec 6>&1 # ...
5
votes
1answer
112 views

understanding the default value of IFS

In my GNU bash version 4.2.8, IFS has a default value of space, tab and line feed by default: usr@T42 ~ $ echo -n "$IFS" | hexdump -C 00000000 20 09 0a | ..| ...
1
vote
2answers
78 views

How to find out all the files in other machines using bash shell script?

I am trying to find out which files are in machineB and which files are in machineC. And I need to run my shell script on machineA to figure out which files are in machineB and which files are in ...
8
votes
3answers
203 views

How to execute a command repeatedly with different arguments?

I'm on Ubuntu. I copied some arguments (separated by newline) and I can use xsel to print them out like this $ xsel arg1 arg2 arg3 arg4 ... Now, I want to use each of these arguments for another ...
3
votes
2answers
141 views

Set difference from two files in unix

I am looking for an efficient way to achieve set difference from 2 files. I do know that grep -vxF -f setA setB gives me B - A. This is what I want, but my files are as follows: setA: 2 4 5 6 set B: ...
4
votes
3answers
2k views

Mac OS X: dircolors not found?

I just switched to a Macbook Air. I installed zsh using homebrew, but when I use some of the code that I (originally had) in my .zshrc, I get an error saying that .dircolors was not found. Below is ...
12
votes
5answers
24k views

Is there a way to see details of all the threads that a process has in Linux?

For Windows, I think Process Explorer shows you all the threads under a process. Is there a similar command line utility for Linux that can show me details about all the threads a particular process ...
3
votes
3answers
185 views

Efficient way to create multiple files

I have been testing find directory which is taking max inodes and while testing I had run touch test_{1..1391803}.txt But it's give me error "-bash: /usr/bin/touch: Argument list too long", now ...
1
vote
4answers
52 views

Write program output to log file containing PID in its name

How can I start a program and write its output to a log file, where the log file contains the PID in its name? I tried program_a > log_$! which doesn't work since $! is the PID of the last ...
27
votes
6answers
9k views

How to test what shell I am using in a terminal?

How to check what shell I am using in a terminal? What is the shell I am using in MacOS?
0
votes
4answers
172 views

Starting with bash: -lt and -gt arguments

I'm starting with bash and I found the following: if test $first -lt $second then echo $first is lower than $second else if test $first -gt $second then echo $first is higher than $second ...
1
vote
2answers
41 views

create file from function

#!/bin/bash # trims trailing spaces and tabs from file, using awk utility function remove_trail() { [ ! $# -lt 2 ] || { echo "Usage: $FUNCNAME file-to-trim out-file"; return 1; } # args ...
0
votes
2answers
55 views

How to reset the file descriptor

I was trying to use file descriptor for printing the lines in the file #!/usr/bin/ksh exec 3<&0 exec 0< file.txt while read LINE do echo “$LINE” done and I am done with my code ,it ...
14
votes
3answers
3k views

Bash: double equals vs -eq

I am doing integer comparison in bash (trying to see if the user is running as root), and I found two different ways of doing it: Double equals: if [ $UID == 0 ] then fi -eq if [ $UID -eq 0 ] ...
3
votes
1answer
107 views

Passing all files of specific filetype in current and subdirectories

I have constructed an elaborate 500+ character command with many arguments and switches to autosign multiple PDF documents. I'm using JSignPDF and I'd like to use it's batch mode including the ...
13
votes
3answers
260 views

What are the responsibilities of each Pseudo-Terminal (PTY) component (software, master side, slave side)?

I am trying to figure out how a tty works1 (the work-flow and responsibilities of each elements). I have read several interesting articles about it, but there are still some blurry areas. This is ...
2
votes
1answer
335 views

KSH styling text based menu using STDERR

Is it possible to format the STDERR in order to have a better looking menu using the select command? I have a simple select select oChoice in $(<tempMenu.menu) ; do case "$oChoice" in ...
2
votes
4answers
91 views

What are SSH_TTY and SSH_CONNECTION?

What are the SSH_TTY and SSH_CONNECTION variables for? On my Ubuntu system both of them are blank; what values should they have?