The shell is unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks. Use this tag for questions applying to /bin/sh and most compatible shells (ash, bash, ksh, zsh, …).

learn more… | top users | synonyms (1)

-9
votes
1answer
61 views

replace the the first line of all .sh files in a folder

Create list of all .sh files in current folder. Check first line of each file in this list and if file starts with #!/bin/sh then replace that with #!/bin/bash. Only modify files that have #!/bin/sh, ...
0
votes
0answers
16 views

Adapt text lines to fixed length [duplicate]

With the shell command fmt -w 30 myfile it is possible to truncate the myfile lines so that their length is at most 30 characters. The result is however not a justified file: some lines will be ...
-5
votes
1answer
63 views

Find the number of files with sizes

Find the number of files with sizes > 100KB in /, /bin, /usr, /usr/bin and /usr/sbin directories and output them in a two column format with the name of the directory and the number of files.
0
votes
1answer
26 views

remove _ as prefix from the multiple files in a directory in Soalris [duplicate]

I have to remove _ which is as prefix for a file. I used: for i in _*.txt; do mv ${i} ${i/#_/''}; done but it does not change the names of the files which has space in between as _abc xyz-abc.txt ...
2
votes
1answer
82 views

What are the Linux shells that allow network traffic management (sending/receiving data to/from `/dev/tcp/host/port`) via redirectors?

Following this Bash tutorial, I have succeded in obtaining the code of a web page issuing simple commands by using this method: $ exec 3<>/dev/tcp/www.google.com/80 $ echo -e "GET / ...
2
votes
2answers
46 views

Seems like some basics are missing from ubuntu…or I haven't set them up?

I can't define a shell variable like so: $a = "hello" echo $a echo a $a a all lead to nothing. Also, this command doesn't work for me: $ echo "HELLO HOW ARE YOU?" | tr '[:upper:]' '[:lower:]' ...
0
votes
0answers
18 views

display JPEG Exif header with od (Octal Dump)

there are several command line tools to show Exif header of JPEG images. I wish to see the same info with od (octal dump) $ jhead 1430472877538-0.jpg File name : 1430472877538-0.jpg File size ...
0
votes
1answer
56 views

How to execute shell commands in a loop from within a bash script?

I am new to bash and need help badly. I want to write a script which will run on my android phone & perform the following things: echo "1" > /sys/kernel/mm/ksm/run wait for 2 minutes: then ...
2
votes
3answers
204 views

How to pass argument with char ( in remote path?

I'm trying to move a file with rsync to a remote location, The file has be be named : DRRS_(H264).mp4 but when I try : rsync -azR output.mp4 user@server.com:encoded/somepath/DRRS_(H264).mp4 it ...
2
votes
2answers
136 views

How to generate a random string in a profile alias?

I have an alias in my server's /etc/profile which generates a random directory on command, like this: alias rdir="mkdir -p ./`cat /dev/random | tr -cd 'a-z0-9' | head -c 8`/" But it turns out this ...
0
votes
1answer
38 views

Writing an install script for CentOS

Every time I deploy a VPS server, I install VNC server. But every time I have to do this: yum groupinstall Desktop yum install tigervnc-server yum install vnc yum install firefox (etc.) Can I ...
0
votes
0answers
22 views

Why rsyslog leaves the last file in spool directory

Suppose I am using a rsyslog remote server (R1) & have a client box (C1). C1 is configured to sync up and use R1 for logging (over port 514; TCP) The spool directory is '/var/log/rsyslog'. Now, ...
1
vote
2answers
24 views

How can I properly escape a string to be passed to a shell with a command argument [duplicate]

How can I properly escape arbitrary commands? For example: sudo -u chris sh -c 'echo "\"leftright\""' The above echos: "leftright" How would I echo out: "left'right" I've tried the ...
2
votes
1answer
96 views

Finding out what sh is [duplicate]

I am writing a set of scripts that I want to be portable, but I need to know whether sh on the current platform stands for bash, ksh, or ash. Is there a clear way to do it? What comes to my mind ...
0
votes
0answers
17 views

What does a hash key preceded by an exclamation key (!#)mean? [migrated]

See the following script from scala tutorial, What does the !# mean? #!/bin/sh exec scala "$0" "$@" !# object HelloWorld extends App { println("Hello, world!") } HelloWorld.main(args)
3
votes
4answers
169 views

Comparing each file in two directories and copying it to one if it differs from it's counterpart

How can I compare all files in two directories and copy the ones that are different to one of the directory. For example, say we have dir1 and dir2: dir1: build.gradle gradle.properties ...
0
votes
2answers
70 views

Shell Script: Sending input to background process

I am using the following script to watch a folder, and if the size changes and a file doesn't exist, it runs a script. #!/usr/bin/sh SCRIPT="dim_import/xdir" while true; do size=$(du -s ...
2
votes
2answers
69 views

How can I setup a separate bash environment with only GNU utilities on OS X?

For the last 5 years, I have used linux as my everyday OS for performing scientific computing. My work recently gave me a Mac that I will be the primary user for the next few months. I keep running ...
4
votes
2answers
76 views

Is it possible to escape quotes within escape quotes within escape quotes within escape quotes?

I'm guessing someone will tell me I'm doing something wrong and dumb and noobish, but I'm trying to script something in the most straightforward method possible and use sudo commands to do something ...
-2
votes
3answers
44 views

Execute the shell script option by option

I have 3 options create a directory,if exist rename it. copy a directory,if exist in target directory rename it. exit 0 these are the options. in execution time to display this options and there ...
2
votes
3answers
58 views

reverse cat files order

I need to do log analysis and I am facing problem that cat access.log* display latest log file first. I tried to sort logs which takes a lot of time because I have logs from couple of years back. And ...
0
votes
1answer
15 views

Bash overwrites the first line when using custom PS1 prompt [duplicate]

My question is similar, but different to, this question. I have created a custom PS1 in my .bashrc, as follows: STARTCOLOR='\e[0;36m'; ENDCOLOR="\e[0m" export PS1="\n$STARTCOLOR\u@\h:\! <\t> ...
2
votes
1answer
54 views

combine two files to single file with combined columns

I am new to linux/unix shell scripting and struggling to combine two files into a single file with all columns from both files. I am providing my example files. File 1 chr loc T1 C1 chr1 100 2 ...
2
votes
2answers
139 views

How to pass shell variable to an awk search pattern?

In my bash script I have a variable that I am trying to pass to a pattern to search for using awk. However what I expected to happen is not working. I have the following text file (text.txt): ...
0
votes
1answer
44 views

Numeric test in bash: integer expression expected

I created a simple script in bash language to do cleaning of the recycle bin in Ubuntu. here is the script "recycle.sh" #!/bin/bash PUBLIC_PATH="/home/fileserv/.recycle/Public" ##### Clean public ...
0
votes
3answers
58 views

Delete all files that DON'T have duplicate names?

Given a large list of files, containing the following: FILE1.doc FILE1.pdf FILE2.doc FILE3.doc FILE3.pdf FILE4.doc Is there a terminal command that would allow me to remove all files that do not ...
1
vote
3answers
70 views

Shebang does not set SHELL in cron

I have a script containing: #!/bin/bash printenv When I run it from the command line: env testscript.sh bash testscript.sh sh testscript.sh every time, it outputs SHELL=/bin/bash. However, when ...
1
vote
1answer
22 views

Can I do a delay delivery in Thunderbird or Evolution

Now we have an option of "Delay Delivery" in Outlook. Can we do something like that in thunderbird/evolution or any other linux client ?
0
votes
0answers
30 views

what is scriptname TODAY 0 mean in crontab?

We have some scripts scheduled in crontab with TODAY 0 or YESTERDAY 0 after the script name. What does they mean?
2
votes
1answer
30 views

Secure share in samba not working, why?

The secure share that I created in samba with a password doesn't seem to work. I have the following on my /etc/samba/smb.conf on a Linux Mint box(3.13.0-37-generic) box. [myshare] ...
2
votes
3answers
42 views

How to make an alias permanent?

I have created an alias: alias shh='sqlplus hfdora/hfdora@hfd1" After creating this alias I was able to enter my database only by typing shh. But after closing my shell, I wasn't able to find ...
3
votes
1answer
37 views

Store specific output to a shell variable

I am looking to store the output of the svn info command, more precisely the revision number into a variable for further processing. I just need the 4 stored. Can anyone help me please? $ svn info ...
0
votes
1answer
12 views

ssh-copy-id doesn't copy to non-default location

Does ssh-copy-id recognize if the authorized_keys file is not in ~/.ssh? I am storing my authorized keys file in a different folder, which I have configured as: AuthorizedKeysFile ...
1
vote
1answer
36 views

How to parse a CSV file based with groups made of specific number of rows?

I have a CSV file which has the following format: Date,Towns,Count1,Count2 6/26/2015,HYDERABAD,234552,0 ,KARIM NAGAR,7520,0 ,RAJAMUNDRY,7248,256 ,KURNOOL,5848,32,0 ...
2
votes
4answers
69 views

What's the name of the environment(?) variable with current terminal width?

I know this is something simple, but I can't recall where it's located/named. Where's the variable for the current width of the terminal stored? I see this answer talks about changing things: How ...
-6
votes
1answer
27 views

shell programing error [closed]

With the following shell script, why I am getting errors syntax error near unexpected token `)' Shell Script 2) echo "enter file for rename"; read f1; echo "enter newfilename"; read f2; mv $f1 ...
1
vote
1answer
59 views

Listing directories and understanding ls

On ls man page, I saw this -d, --directory list directory entries instead of contents, and do not dereference symbolic links on my current folder: drwxr-xr-x 2 oracle oinstall 4.0K Jul ...
1
vote
2answers
64 views

“Argument list too long” in for loop

My shell script look like this: #!/bin/bash for file in *.fasta do signalp $file > $file.txt done In the working folder I have 18.000 .fasta files. I want to run each through the signalp ...
0
votes
1answer
42 views

ln -s removes part of a a file name, filename passed as a var

I use a script to link some of the files I download to a different directory. When there are "-" in the file name, ln - s wont read the path correctly, even though the variable will be logged ...
5
votes
3answers
206 views

How to forward between processes with named pipes?

The /tmp/in, /tmp/out and /tmp/err are named pipes, already created and opened by some process (for reading, writing and writing, respectively). I would like to create a new process that pipes its ...
2
votes
3answers
66 views

How can I copy three partitions of my disk with a specific beginning and ending using dd?

Using the fdisk -l command I got the following answer: Device Boot Start End Blocks Id System /dev/sda1 * 2048 28266495 14132224 27 Hidden NTFS WinRE ...
4
votes
1answer
84 views

How does the “subl” command work?

To open a file to edit in gedit I run gedit sample.py &. But with Sublime Text it is simply subl sample.py. This opens the file to edit and it doesn't run in the background (in my shell). How ...
1
vote
1answer
24 views

Installed PDFInfo with Homebrew Cask but no command associated with “pdfinfo”

First, please excuse this very basic question. I'm sorry I have to ask it, but it's very difficult to find your way around the shell at the beginning. I installed pdfinfo with Homebrew Cask: brew ...
0
votes
4answers
59 views

Copying Only Directories With Files

I am trying to copy files and the directory it is in to another location. I can find the path like this: find ~/dim_import/* -type f ! -name xdir | cut -d '/' -f 5-10 which outputs ...
2
votes
1answer
32 views

Can we broadcast in tmux

Now we know that we can do a broadcast all or to a specific group in terminator and execute commands simultaneously on every window. Can we do the same inside a tmux session?
3
votes
1answer
44 views

Passing list of ignored directories to `tree` command [duplicate]

I'm writing a script in which I need to generate a tree of directories. How to pass to tree a variable with list of directories to ignore? And those directories are with spaces in name. I tried ...
-1
votes
0answers
32 views

not able to match the exact directory name [duplicate]

Issues in the below code : It should execute the loop when $a should exactly equal to the directory BE but the loop is executing for many names like BE_REP , BE_REPPP etc Pls loop into the issues. ...
1
vote
1answer
40 views

Recursively count occurrences of a word in identically named files in different directories

I've got several different directories that contain different versions of some files. I want to count a symbol in all versions of the same file. Here is an example of the hierarchy. directory ...
0
votes
2answers
25 views

Braces don't work when there is a single element

I am able to scp files based on their extensions as, scp sk@localhost:/home/sk/*.{txt,text} . But when I try to scp a single extension type, it fails, scp sk@localhost:/home/sk/*.{txt} . I was ...
1
vote
1answer
57 views

sh - Using Arguments in .profile functions

I want to use an argument in the function I created in my .profile file. I want to ask for input if no argument is given, otherwise set a variable to $1. When I check $1 to see if it is empty, I ...