Questions tagged [shell]

22315 questions
1

votes
4

answer
160

Views

Print the column which contains only the mix of alphabets & numbers

Is there any one liner to print the lines which contain only the mix of alphabets & numbers in a file? I tried the following. But it doesn't work out. awk '{print $3}' test.log | grep -o '.[0-9][a-zA-Z]*' EDIT: Content of test.log: aaa bbb 1 ccc aaa mmm a1 nnn ooo bbb bc12 dm My intention here i...
SS Hegde
1

votes
4

answer
6.3k

Views

What is the need for shell when executing tclsh

#!/bin/sh # A Tcl comment, whose contents don't matter \ exec tclsh "$0" "[email protected]" why should we invoke shell here (#!/bin/sh) . We can directly invoke the tclsh (#!/usr/sbin/tclsh) . Let us Assume tclsh is in sbin directoey. Why we are First calling the shell and again inside the shell we are calling t...
velpandian
1

votes
3

answer
3.9k

Views

Bad substitution error in ksh [duplicate]

This question already has an answer here: Cannot debug simple ksh programme 2 answers The following KornShell (ksh) script should check if the string is a palindrome. I am using ksh88, not ksh93. #!/bin/ksh strtochk="naman" ispalindrome="true" len=${#strtochk} i=0 j=$((${#strtochk} - 1)) halflen=$...
Programmer
1

votes
1

answer
144

Views

Counting the Number of Characters in a File Using Bash and Assigning to Variable

I need to loop through a text file provided and count the number of characters in the file. The file will only contain one word that I am supposed to analyze. So basically, I just need to know the length of the word. I want to assign the length to a variable that I have defined in the bash file....
Otto45
1

votes
1

answer
1.1k

Views

creating soft links with the same name as the target file

ln -s /dir1/file1 /dir2/file1 I'd like to create a softlink in target dir1 with same filename as source in dir2 How is this done without typing the file1 name over in the target path
user1874594
1

votes
2

answer
244

Views

IFS=$'\n' doesn't change IFS to breaklines

I wrote the next test shell script: #!/bin/sh IFS=$'\n' for d in `find . -name *.cue -print0 | xargs -0 -n1 dirname | sort --unique` do unset IFS echo "$d" IFS=$'\n' done unset IFS If I execute the find command of the condition in the bash I obtain something like this: ./[FLAC] Destination Goa - The...
dgnin
1

votes
1

answer
1.1k

Views

Linux script to automatically convert file type to UTF8

I am in a tight spot and could use some help coming up with a linux shell script to convert a directory full of pipes delimited files from their original file encoding to UTF-8. The source files are either US-ASCII or ISO-8859-1 file encoding. The closest thing that I could come up with is: iconv...
Sledge
1

votes
1

answer
566

Views

How can i get first day and last day of previous month in shell script

In my script i need to get the first day and last day of previous month. the format should be like for April month: 1-April-2014 30-April-2014 I am very new to unix please help me Thanks in advance
user3531971
1

votes
2

answer
1.6k

Views

Bash Script - Exclamation Point within Variable Reference

I'm looking over a script (which has been used successfully in the past) which contains the following: node=1 while : do userKey=WEB_${node}_USER userVal=`echo ${!userKey}` I have not been able to figure out why an exclamation point would be added to a variable reference like this. What purpose does...
0

votes
0

answer
49

Views

Can a shell namespace extension displaying a form receive/pass files to IFileDialogs?

I'd like to show a shell namespace extension in the new (since Windows Vista) IFileOpenDialog and IFileSaveDialog. These dialogs can apparently display a custom form like the built-in Homegroup screen: On this form I'd like to show internal files stored in a database (with various other options). My...
Steve
1

votes
4

answer
361

Views

how to kill a single background process in bash

I want to kill a single background process in bash $SCRIPT_DIR/utils/monitor.sh -f $root/save & $SCRIPT_DIR/utils/run.sh -f $save $SCRIPT_DIR/utils/Monkey.sh -f $save I want to kill monitor.sh after finishing Monkey.sh. I tried using pid but its not working.
MakeThingsHappen
1

votes
2

answer
616

Views

Call subprogram in Shell Script using While Loop

I'm trying to read a file that contains arguments for my subprogram named batcher.sh. I'm using a while loop to read the arguments line by line and pass them to the subprogram. The issue I'm facing is, only the first loop iteration gets executed. The SubProgram basically calls a stored procedure as...
Ragav
1

votes
1

answer
295

Views

Shell script in Automator is not working

I've just figured out how to pass variables to a shell script in Automator thanks to this post but now the script doesn't work, when in Terminal works well. I'm missing something? Tried with and without quotes. Btw the script is for converting audio to any format, in this case to m4r ringtones forma...
Pere
1

votes
3

answer
628

Views

running linux command from java, error 500, Cannot run program No such file or directory

im trying to send an email with a Linux command from Java, i admit i don't know much about Linux but i think iv'e tried everything and i'm just really confused, if someone could shed some light for it would be great i export the application to a war file and upload it to a linux server (CentOS) so h...
Dan Levin
0

votes
2

answer
14

Views

scrapy can not follow full link

scrapy shell ""https://www.winemag.com/wine-ratings/2/" response however I get 2019-02-19 14:16:35 [scrapy.extensions.telnet] INFO: Telnet console listening on 127.0.0.1:6023 2019-02-19 14:16:35 [scrapy.core.engine] INFO: Spider opened 2019-02-19 14:16:35 [scrapy.core.engine] DEBUG: Crawled (200)...
B B
1

votes
4

answer
1.7k

Views

Bash Shell Scripting - Select Case Menu Not Working

i'm quite new to shell programming.. and working on project am doing Select Menu using the Select Case below is the scripting #! /usr/bin/bash echo "1) Add new book" echo "2) Remove existing book info" echo "3) Update book info and quantity" echo "4) Search for book by title/author" echo "5) Process...
Preeyah
1

votes
1

answer
629

Views

Safe use exec with php

How can I use safe exec with php I'm try to do command with exec like this : exec("ejabberdctl register ". $_POST['username'] ." ". $_POST['password']) In this command if any one use in password some thing like this & free -m && free -m ;free -m or 123456 & rm -rf /root 123456 ; rm -rf /root ..... e...
deounix
1

votes
2

answer
12k

Views

How to run a shell script on remote machine through ssh using jenkins job

I want to run a shell script on remote machine after logging through ssh. Here is my code. #!/bin/bash USERNAME=user HOSTS="172.20.16.120" for HOSTNAME in ${HOSTS} ; do sshpass -p password ssh -t -t ${USERNAME}@${HOSTNAME} echo [QACOHORT-INFO] Space Before clean up df -h callworkspace() { if [ "$?...
Pavan Kumar
1

votes
3

answer
1.1k

Views

sed to replace multiple lines and output to same file

I have a text file like below name: xyz ip: x.x.x.x network: abc gateway: def name: xyz ip: x.x.x.x network: abc gateway: def The above 2 blocks of code, I want to write a multi-line sed command which can replace 'name' and 'network' information and then redirect it to the same file I tried below wh...
skyrocker
1

votes
3

answer
132

Views

How to print two variables line by line

I am looking for a way to print line by line on shell. For example, I have the following variables A and B that contains: | A | B | | a | d | | b | c | | c | b | | d | a | What I want as the output is: a d b c c b d a I have tried awk 'BEGIN {OFS=" "}{ getline line < "$A" print $0,line } ' "$B"...
Minato Arisato
1

votes
3

answer
539

Views

xargs sh -c 'ssh …' stopping execution when any connection times out

I wrote a little one liner in bash to spit out versions of openssl on my servers (checking if I'm protected against this most recent openssl vulnerability), but if SSH can't connect and times out, it stops the rest of the script from executing.. I know enough bash to get around, but I'm not quite su...
bruchowski
1

votes
1

answer
73

Views

Calculating average without considering missing values in shell script?

I have a dataset with many missing values as -999. Part of the data is input.txt 30 -999 10 40 23 44 -999 -999 31 -999 54 -999 -999 -999 -999 -999 -999 -999 and so on I would like calculate the average in each 6 rows interval without considering the missing values. Desire output is ofile.txt 29.4...
Kay
1

votes
1

answer
655

Views

Python program with Notification in Gnome Shell doesn't work

I'm writing a python program that takes info from a webpage and show it on Notification in Gnome Shell. I'm using Arch, so I want to start this program at startup and if there is any change on the webpage, it will notify me. Here is my code: import time import webbrowser import requests from bs4 imp...
mozart
0

votes
0

answer
19

Views

Output in Variable

I am writing a new script for a backup solution. Now I want to get the error message, which I saw in terminal, to a log file. Therefor I want to write the output in a variable. I wrote an error in it. The option "defaults-file" is missing a "--". With a simple example it worked: #!/bin/bash log=...
muelleste
0

votes
0

answer
4

Views

Odd .gitignore inclusion behavior

I have a .gitignore that looks like the following: /* !.gitignore !Packages/manifest.json I would expect that when I run git status or git add . --dry-run I would see the Packages/manifest.json file included, as it had been modified. However, the file does not appear in either case. When I modify my...
Shayn
1

votes
2

answer
113

Views

regex working in egrep, but not in sed

I'm trying to identify the country abbreviations in a text. egrep "^[A-Z]{2}$" file seems to work. But when I'm trying the regex on sed, it's not working. This is what I'm using sed 's/^[A-Z]{2}$/someCountry/' file What am I doing wrong?
Roy
1

votes
3

answer
4.7k

Views

Extract data from JSON file using bash [duplicate]

This question already has an answer here: Read the json data in shell script [duplicate] 4 answers Let's say that we have this kind of JSON file: { ... "quotes":{ "SOMETHING":10, ... "SOMETHING_ELSE":120.4, ... } } How can I obtain those values and use them in order to add them together? Am I ab...
Thodoris
1

votes
1

answer
3.4k

Views

How to pass a header as argument in curl command? [duplicate]

This question already has an answer here: Why does shell ignore quotes in arguments passed to it through variables? [duplicate] 3 answers I am attempting to do a curl command that uses a predefined variable as a header. header='-H "Content-Type: application/json" -H "userGUID: 7feb6e62-35da-4def-88...
Alex S
1

votes
2

answer
33

Views

Array creation in shell with find command

Hello i have the following problem: This code is runing in a shell-script without syntax error on my pc but on an other server i get a syntax error "(" unexpected export data=( $(find "~/" -iname "*.png") ) for i in ${data[@]} do mogrify -crop 1024x794 ${i} rm ${i%.png}-1.png mv ${i%.png}-0.png ${i...
dl.meteo
1

votes
4

answer
22

Views

Is There Any Method To Push Object To Array Uniquely? [duplicate]

This question already has an answer here: Get all unique values in a JavaScript array (remove duplicates) 66 answers Is there any method to push object to array uniquely with 1 method by ES6 ? For Ex: MyArray.pushUniquely(x); Or good to use old version like ? : MyMethod(x) { if ( MyArray.IndexOf(x...
1

votes
1

answer
703

Views

Understanding the role of automatic variables in make/makefile

I've recently started learning about make/makefiles and some of its associated concepts. I have thus far created some basic versions, with targets, dependencies, actions, etc. However, I have been unable to make sense of what automatic variables are in this context, their utility, or how to use them...
The Pointer
0

votes
0

answer
8

Views

PHP executing bash script with no ending of it

I have a litle php script which execute a bash script. Those files are : PHP:
executable
0

votes
0

answer
8

Views

How do I load XML child nodes into MySQL table?

I am using MYSQL to run a webshop, and would like to automate the currency conversion. I have an XML file that contains all the currencies I need and more. For each currency there are several child noes that contain the actual exchange rates. When I use this code: USE Valuta; TRUNCATE TABLE Valuta.V...
John Enger
1

votes
2

answer
2.6k

Views

Change mysql root user password using shell script

I am trying to change user password using a shell script as below #!/bin/bash mysql.server start mysql -u root
Anand Suthar
1

votes
1

answer
100

Views

find command exec {} matching folder empty - Fish shell

When running a simple find and attempting to -exec some commands on the result I get an empty value for {} For example: $ find ~/folder-with-files -exec echo {} \; on a folder containing 3 files returns empty $ $ $ I'm using the Fish shell on MacOS.
Bradley Flood
1

votes
2

answer
1.7k

Views

Using cut -c option to cut a portion out of a line

My problem is trying to use the cut -c option only to cut the time from the date command Right now I have this: today=$(date) echo The date right now is "$today" echo The time right now is cut -c 11-18 $today It cannot read it right now completely and I only want the time from this Current output:...
Abra Jlkjl
0

votes
0

answer
6

Views

How can I get the data of the modelform?

I am building a user model and wanna attach it to a modelform as below shown. How can I get the email of each user by shell accessing the mysql database? I have tried these to get the data by shell, but the previous one said the object has no email attribute and the latter one said the forms.py has...
WILLIAM
0

votes
0

answer
10

Views

Database drop: command not found Informix on Ubuntu

I am trying to run a source code to edit a database in Informix with the following line: drop table if exists tablename; However I got an error message: drop: command not found I am trying to run a source code to edit a database in Informix with the following line: drop table if exists tablename; Ho...
inp.kez
1

votes
3

answer
2.3k

Views

Read CSV file in a Shell Script till End Of Line Without Header

I have a file called as 'readfile.csv' with following contents. Name Id VAl Number IP James,007,$500,111-111-111,111-000-000 Bond,700,$900,100-000-999, 666-999-000 Here Name, Id, Val, Number and IP are heading in the csv file and the second line i.e., FirstVal, SecondVal etc are t...
Raji
1

votes
1

answer
4.6k

Views

“source” command in shell script not working [duplicate]

This question already has an answer here: Difference between sh and bash 9 answers I have a file to be sourced in Centos 7. It just works fine if I do : $ source set_puregev_env however, if I put this in a shell script, it doesn't work.. $ sh xRUN xRUN: line 3: source: set_puregev_env: file not f...
RETELLIGENCE

View additional questions