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)

0
votes
1answer
10 views

find files with two types of extensions last modified over 30 days ago

I want to find all the files in a directory that have not been modified for at least 30 days and end in .xml or .out. This is my attempt to cobble together a couple of references to build the right ...
0
votes
3answers
24 views

Change Multiple (Including No) File Extensions

If I have a directory of files, where some files have an extension like .html and some files have no extension, how do I change them all to, e.g. .txt?
0
votes
0answers
32 views

How to password protect a file?

I have the script called Linux.sh. I want it to be executable by everyone on mobaxterm(collection of Unix utilities for windows machine), but others should not be able to edit the script. Only i ...
0
votes
1answer
19 views

Which way is safer to read data from /sys

I am attempting to write a program that will monitor the temperature of various hardware components. The language I chose for it is Java. Now there are two ways I could read the temperatures: a) Do ...
0
votes
5answers
140 views

How to get current working directory? [duplicate]

I want to have a script that takes the current working directory to a variable. The section that needs the directory is like this dir = pwd. It just prints pwd how do I get the current working ...
1
vote
4answers
44 views

Completely buffer command output before piping to another command?

Is there a way to only execute a command after another is done without a temp file? I have one longer running command and another command that formats the output and sends it to a HTTP server using ...
2
votes
2answers
27 views

Why is a variable passed to the su command, but not an array from the same scope?

In the example below, why does $var get passed to the su in the start function, but not the array modules ? #!/bin/bash var=cat modules=( one two three four ) start() { su gleventh -c "for i in ...
0
votes
2answers
41 views

Why would the prompt get overwritten?

p_ash-3.2$ cp some_file1234.html /some/loc/ation/ofthe/some_file1234.html.html_Backu Have been seeing this intermittent issue with the command-line, while typing longer lines as part of any command, ...
1
vote
1answer
23 views

remove lines where a field's value is less than or equal to 3 - sed or awk?

I need to remove every line that has a value of 2 or less in the 8th field (column). My data looks like this: 12-31 Airport 189 379 41 49.70946503 -124.91377258 2 2880 30.8 01-01 ...
0
votes
0answers
23 views

convert from one memory format to another and find the difference between them

Using shell scripting, how can I convert from one memory format to another and find the difference between them? I want to compare current rate and previous memory rate (Where we need to compare ...
0
votes
2answers
17 views

How to search parenthesis by ack

I want to search for a parentheis ( using ack, but neither using ( nor \( worked. The first one ("(") is recognized as a multiple line command. The second one ("\(") is treated as an invalid regular ...
-2
votes
0answers
20 views

print character in specific rows and columns [on hold]

I have one file F1 having data Column 1 will represent character and column 2 represent multipliers (number of time a character suppose to be repeat). file 1 as input: A 2 B 4 C 4 D 6 ...
1
vote
1answer
51 views

how to locate a name-not-specified file in bash? [on hold]

I have a bash like this to easily upload a file to my server: FILE=../"$1"/1.txt scp 1.txt remoteserver #upload the file to a remote server. The $1 is for input directory and I have a lot of ...
14
votes
2answers
692 views

Renaming the current directory from a shell - possible?

Is it possible to rename the current working directory from within a shell (Bash in my particular case)? If I attempt to do this the straightforward way, I end up with an error: ...
1
vote
1answer
30 views

Specify the type of field to modify in a file

I have a list of clients, "code", "name", "location", "etc" and I want to make a function that asks the employee to give the client's code and then the field he/she wants to change. For example, ...
2
votes
3answers
45 views

Calculate date difference between Last modified date of a file and NOW using shell script

I am trying to calculate the time elapsed since the log file was last updated. I guess following commands will be used lastUpdate=$(date -r myLogFile.log) now=$(date) How can I subtract them and ...
3
votes
5answers
157 views

Pick the latest file based upon the sequence number given in the file name

I have a requirement, I have few files in a directory, I need to pick the oldest one for processing. For Exp: I have below files in /tmp directory: Sample_0000237826-001_xyz.dat ...
0
votes
0answers
9 views

sending NEDIT to background on launching

I have this problem - for opening nedit it will open in the foreground. Then either you open it using & ex- prompt> nedit & is there any way where I can open nedit directly in the ...
2
votes
3answers
41 views

space check on unix machines

I am having space issues on 1 of the UNIX servers. I am executing the below command to check the space utilization. But this command is very slow and takes hours of time to give the result. du -sg * ...
0
votes
1answer
20 views

Error with sed on MAC OS X invalid command u

Im french sorry in advance for my bad english... So i have an error on MAC OS X when im using sed sed -i '' '/user_pref("mail.identity.id1.reply_on_top", 1);/ a\ ...
1
vote
1answer
42 views

loop through multiple folders and perform commands then write to file

I have 10 folders that I want to loop through while executing the following command: awk 'FNR > 1' *.csv | sort -sk 1,2 | sort -sk 3,3 > ${f}_appended.dat With a for loop wrapper, like ...
1
vote
1answer
48 views

Shell script runs diffrently based on working directory.

I have a script which runs differently based on current working directory. Basically it processes an .ini file and takes parameters from it and runs mysql backup. Script is running as root user. ...
0
votes
1answer
14 views

Having problem with mysql dbdump when password starts with special character

I am trying to take a db backup with a php file that is running from a cronjob. It was running fine when I tested with sample db. But when I used the actual db there was an error. I am using ...
-1
votes
1answer
38 views

Can you please tell me what is wrong in below script?

script : it is giving below error. please help me. basically i need to get email when memory exceeds some limit. error : ./vamsitest.sh: line 10: [: missing `]'   #! /bin/bash # Total memory ...
0
votes
1answer
19 views

Unable to extract to specific directory

I am trying to extract to file to specific directory but it doesn't produce result Operating system : SunOS Command: zcat /export/home/tceng/Desktop/temp/3.tar.Z | tar -xf - -C ...
2
votes
1answer
30 views

Windowless xterm? (Faking a terminal for a process)

I'm fighting with a rather odd problem with Matlab. The startup script is located in /opt/matlab_2013b/bin and is called matlab. When I run it in terminal, it works fine. But I want to make a ...
0
votes
3answers
52 views

How to use password in shell scripting

I am writing a script which greps for for multiple files from 3 log files. One of the log file is created as superuser and every time it executes it prompts for password. How do I put it the same ...
1
vote
0answers
31 views

delete non important characters from command output

the version command in my Linux machines display the following output version Red.Hat.OS. release..........5.5 APP.Release.............4.2.0.0-02 how to remove the middle "." dot character ...
0
votes
2answers
34 views

What is difference between Power broker utility and sudo command?

I got a little clarity with the following answer on this Source Symark Power Broker is a commercial package. Sudo is an open source tool.
4
votes
2answers
258 views

How to echo `single quote` when using single quote to wrap special characters in shell?

I'm reading shell tutorial today from http://www.tutorialspoint.com/unix/unix-quoting-mechanisms.htm In which it mentions: If a single quote appears within a string to be output, you should not ...
1
vote
1answer
39 views

When did bash quit exporting SHELL?

I upgraded a Debian box from stable to Jessie and I noticed that SHELL is no longer exported, so screen and similar programs start dash for subshells instead of bash. When was this change made and ...
8
votes
4answers
627 views

Spaces next to pipes

I've seen history | grep blah and history |grep blah; and history|grep blah also works, though no one ever seems to use it. Is there any significance in the spaces (e.g. piping to/from different ...
0
votes
2answers
42 views

Gzip file but excluding some directories|files and also append current date

I'm looking for a way to create a .tar.gz file from a directory but I have some doubts. I'm know that the command for create the file is: tar -zcvf /path/to/compressed/file.tar.gz /path/to/compress ...
0
votes
1answer
25 views

explain this shell command with redirection and pipe

I can understand the statements like. bzip2 --version >/tmp/list_right 2>/tmp/list_error bzip2 --version >/tmp/list 2>&1 But I don't understand the statement: bzip2 --version ...
1
vote
2answers
68 views

use “read” command to pass lines as positional parameters to a shell script

The following file runs, but not doing anything, yet it does not error.... while read dates; do ./avg_hrly_all_final.sh ${dates}; done < ./dates_all.csv I have a list of dates in ...
1
vote
1answer
19 views

Multi-platform web based terminal emulator

Is there a web-based terminal emulator compatible with all device like pc browser, smarthphone and tablets (android and iOs)? I tried shellinabox, but with iOS doesn't work correctly (can't activate ...
1
vote
0answers
38 views

Bash cannot see PATH update

I am running Debian on a VM. I login to the GUI and go to Applications > Accessories > Terminal. # echo shell: /bin/bash I modified ENV_SUPATH, ENV_PATH inside of /etc/login.defs. I restarted ...
1
vote
0answers
59 views

Sed regex printing into a file.txt

I'm connected to a MQTT stream, and I filter out the data by entering : mosquitto_sub -d -t +/# 2>&1 | sed -n "/PUBLISH/{s|.*\('.*',\).*|\1$(date),|;N;s/\n//;p}" into the Ubuntu terminal. ...
4
votes
2answers
51 views

How to get the real name of the controlling terminal?

How can one get the real name of the controlling terminal (if there is one, else an error) as a pathname? By "real name", I mean not /dev/tty, which cannot be used by other arbitrary processes to ...
0
votes
1answer
31 views

looping through a file on 2 lines in shell

I have a file which looks like this: >a TCCACTCCACGC >b ACCTCCAG I want to loop through the file in such a way that it takes into account 2 lines at a time i.e >a and its sequence and then ...
2
votes
1answer
43 views

attempting to put dynamic input data in a variable via cat method

I'm attempting to write a bash script that should be able to collect data from ttyS0 and put in a variable. I need to talk with a device on the serial line, that is a module able to receive AT ...
4
votes
2answers
55 views

How can set a row as column in unix [duplicate]

How can I set a row as column in Unix. Example: name : Keshav sub : C++ branch: cse DOB :22/09/1990 company:NONE name : Vijay sub : Java branch: cse DOB :22/09/1985 company:NONE I want output ...
0
votes
2answers
51 views

how to save the contents of a webpage in a file using shell script

how to save the contents of a webpage in a file using shell script. Web page is using URL, username and password to open. curl -O odcview:password ...
10
votes
3answers
961 views

What's the difference between semicolon and double ampersand && [duplicate]

What is the difference between echo "Hello " ; echo "world" and echo "Hello " && echo "world" Both seems to run the two commands after each other.
-1
votes
0answers
16 views

Count Unique values of Variable in Unix [closed]

I have stored a column value in a variable I want to count unique values in the variable. How can I do this?
4
votes
2answers
61 views

How to delete part of a binary file without copying

I need to delete the first 2 bytes of a 6MB file. However, this is an embedded Linux with only 32 Mbytes RAM and less than 1 MB free flash memory. I tried using dd, as: 1 - # dd bs=1 skip=2 ...
0
votes
0answers
30 views

Unrecoginzed option: using 'getopt' cmd in shell script [closed]

What is wrong in the command: if ! options=$(getopt -n myscript -l a:,b:,cc:,dd:,ee:,ff:,gg:,hh: -- "$@"); then exit 1; fi I get an error msg: mhagent: unrecognized option '--hh' options=' --aa ...
1
vote
1answer
30 views

if command in find -exec

I was just trying to list all directories and files under current directory and also write if they are file or directory with the following command: find -exec echo `echo {} : ;if [ -f {} ]; then ...
0
votes
2answers
30 views

What I am doing wrong with this bash variable? [closed]

How can I insert a variable into a command? In the case below, I need to concatenate the command with the variable file name. #!/bin/bash # Define a timestamp function timestamp() { date +"%D-%T" ...
1
vote
1answer
37 views

How can I get $PATH to always include $(pwd)/sub_directory/.bin

If the path ~/dev/project1/node_modules/.bin/ionic exists, and my working directory is ~/dev/project1, I would like to be able to just type ionic and hit enter. I could include all those ...