Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).

learn more… | top users | synonyms (2)

0
votes
2answers
122 views

How to Lookup the values of an index values from a big data file?

I have a data file (data_array.txt in the example) and index file, index.txt, at which I want to extract the data from the data file that have the same ID in the index file and store in to a new file, ...
0
votes
1answer
356 views

Copy file while replacing text in it

I'm writing a script to publish a webapp. While copying files, I must replace a placeholder current_date in a file with the current date. I would start with something like this to define the date ...
0
votes
3answers
2k views

Convert Month Number to Month Name

is there a way to convert month number to name? example: 2013-10-22 will become Oct 22 I don't have the GNU date and my OS is AIX.
0
votes
1answer
430 views

List of 'if' switches anywhere? [closed]

Is there a list of all the if switches for use in bash scripting? Sometimes I see someone using it and I wonder what the switch they're using actually does. Example is the -z in this one. I know how ...
0
votes
1answer
526 views

Convert .out file to .pdf using shell script [closed]

I have a .out file I want convert this file to PDF format. Is there any script available for this? File Format :o53770855.out I want to convert this into o53770855.pdf
0
votes
1answer
99 views

Converting a loop of code to function

I want to retry a command for 5 times with an interval of 20 seconds. I want this command to be passed as a method parameter. How to do it? And once the function is written how to pass the value to ...
0
votes
1answer
77 views

How do I change working directories with KDialog?

Use-case: I am working in the terminal in /path/with/a/very/long/name and I want to change to some other directory that is deeply nested. But I don't know the path by memory. So I want to browse via a ...
0
votes
1answer
33 views

how to display I/O file on shell [closed]

I am writing shell script and I need to display my output at the same time however it doesn't work with 2> somefile.txt and if I do | tee -a somefilel it will not overwrite which I need to . <> ...
0
votes
4answers
1k views

How to do a “if not” in Bash without a test?

I would like to use the return value of a bash function in a 'if not' statement. The following is an example script: #!/bin/bash function myfunction () { if [ $1 = "one" ]; then return 1 elif [ ...
0
votes
1answer
176 views

set command with — flag

I have a file (called text) that contains two fields of strings (separated by space) like what follows: 1.2.3 version1 When I use set command as follows, I have the first field in the $1 and the ...
0
votes
3answers
370 views

using find, exec, sed to manipulate strings as args to another program

I can use find like this find -type f -path "./src*" -name "*.php" to find a list of files. For example ./src/Superuseradmin/Model/Mapper/UUID.php What I need to do is manipulate each string in the ...
0
votes
4answers
136 views

concatenating multiple files with multiple headers

Im trying to concatenate multiple files with multiple headers to have one file with all the information in it for example. File 1: Numbers 1 2 3 Letters A B C File 2: Numbers 4 5 6 Letters D E ...
0
votes
1answer
578 views

Why doesn't this variable assignment work when using tee?

Consider: $ FILE_NAME=`(cat somefile | head -1)` | tee -a dump.txt $ echo $FILE_NAME $ Now, why doesn't the output of (cat somefile | head -1) reach the standard input of tee ..? If the output ...
0
votes
1answer
122 views

How given script makes executables in /usr/local/bin/

While doing project , I found a script that is bounced over my head. Can you help me to understand this script . Please explain this script step by step. SCRIPT if ! [ -f /usr/local/bin/XXX -a -f ...
0
votes
1answer
232 views

top not working

My below cronjob is not working. What am I doing wrong here?? */5 * * * * /usr/bin/top -n1 | head -10 >>/tmp/load.txt
0
votes
1answer
953 views

Shell script to delete all files which are older [duplicate]

Possible Duplicate: Deleting files by age Write a shell script to delete all the files which are "n" of older that current day, where n can be 3days. 2days, or 1 year etc. The above script ...
0
votes
1answer
2k views

What is the fastest way to process line by line in bash? [duplicate]

Possible Duplicate: How to loop over the lines of a file? Let's say I cat a file and I want to run a bash command on each line and write each line as output. How can I run a bash command ...
0
votes
1answer
149 views

linux/solaris + manipulation of Standard Output

I run the following line on linux/solaris machine ( all output will write in to /tmp/Log from application.bin ) ./application.bin 1>>/tmp/Log We can see the content of the /tmp/Log file ...
0
votes
1answer
3k views

Script failing with “command not found: ^M”

When I try to run the following script in zsh, via the command /bin/zsh ~/.set_color_scheme.sh I get the following error: command not found: ^M The script has u+x permissions and it used to work on ...
0
votes
2answers
243 views

Autentification on SSH connection in OneLine [duplicate]

Possible Duplicate: Shell Script for logging into a ssh server I need to connect via SSH to a remote server, however I must do this with out interactive mode and with out use Public keys ...
0
votes
1answer
762 views

Calling a script in ~/.profile stops my logging in

I placed a call to a bash script in my ~/.profile. The script executes a CLI program to dim my screen at login. However, Gnome doesn't continue to log me in to my standard desktop after running the ...
0
votes
2answers
582 views

How do you wrap executable commands so that they work in an alias or function?

I'm still getting around the quirks of shell scripting, but I feel like I'm getting a little more comfortable with it. I've been trying to create an alias to generate a tar file that I have to create ...
0
votes
2answers
1k views

How to run a shell script containing an awk command

How to run this script (called count.sh)? awk 'BEGIN{ x=0 ; while (x < 5) { x+=1 ; print x ; } }' I'm trying to run it with sh count.sh but it's giving me an error.
0
votes
1answer
51 views

bash script programming question

Why the stomach of cat has ": No such file or directory" ? Help me please! #! /bin/bash if [ $# != 1 ] ; then echo wrong arg,please input one arg exit 1; fi if grep '^[[:digit:]]*$' ...
0
votes
2answers
46 views

Percent signs and environment variable in a shell script

While troubleshooting an issue, I came across these entries given below in one of the shell scripts used by our application. This was written by someone who no longer works in the company and I am ...
0
votes
2answers
36 views

Can't use argument in bash date calculation script

The following bash script won't work. I need to calculate the date depending on the number of days since 14th Oct 1582, where the argument will be the number of days. d="$1" date -d '14 Oct 1582 + ...
0
votes
2answers
49 views

Bash getting integer expression expected

I have following script to check disk usage #!/bin/bash # set alert level 90% is default ALERT=10 OIFS=$IFS IFS=',' storage=$(df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " ...
0
votes
1answer
53 views

Read line from file, manipulate, and then append to another file

To pool specific content from a batch of files, I do for ID in {92..128}; do sed '3q;d' directory_$ID/stats done Now what if want to put the $ID in front of each line read (preferably shifting ...
0
votes
1answer
51 views

how to delete specific characters in a txt file

Please i need some help! I have these lines in a txt file: 1 Q0 /home/nikol123/Downloads/Ergasia_1/Ergasia_1/metadata/13/120411.xml 1 1 Q0 ...
0
votes
2answers
123 views

proper way to iterate through contents in a directory [duplicate]

I need to iterate through every file inside a directory. One common way I saw was using the for loop that begins with for file in *; do. However, I realized that it does not include hidden files ...
0
votes
1answer
191 views

Null message body; hope that's ok

I have the following command below as part of a cronjob. When I run the command via cron or at the command line, I get Null message body; hope that's ok. The contents of the email are empty but when ...
0
votes
1answer
57 views

Command to list all usernames on a Linux server

What is the command that allows one to generate a list of all the usernames of authorised users on a Linux server? I have tried getent passwd | cut -d : -f 1 | xargs groups and less ...
0
votes
3answers
110 views

how to generate only one special character in this password generator

I have a command which generates password with multiple special characters. How can I make it to generate only 1 special character? # Generate a random password # $1 = number of characters; defaults ...
0
votes
1answer
38 views

How to set the environmental variable for my scripts same as the users shell? [closed]

I want to know how to set the environmental variable for my scripts that I have written such that they are the same as the user. This way I can save time in giving an absolute path of the command.
0
votes
4answers
379 views

sftp script to get a file from remote machine

I use a script, which contains the line: sftp $FTP_USER@phcsftp.pearsoned.com:/dir/file.txt When I run the script, it asks for my password: user@phcsftp.pearsoned.com's password: However, ...
0
votes
1answer
47 views

Is there a way to create a new file and insert text into this file all with bash? [closed]

I need to change and create several configuration files for some kiosks at work, is there a way to do this with a single bash script? I've heard about SED but the documentation is confusing, could ...
0
votes
2answers
87 views

Intro to shell scripts with basic application: how do I set my computer to make an archive of a particular folder every day?

I've got a situation where I need to give some people access to my dropbox folder. Already so far they have deleted huge folders full of important data. Their computer skills could use a bit of ...
0
votes
2answers
158 views

How to kill a process running in specific script

I have two script files running simultaneously. I just need to kill the java process running in one script without affecting the java process in the another one.
0
votes
1answer
158 views

Using bash's “source” command return error though it successfully read config file [duplicate]

I want my bash script to read parameters from config file. Here is what inside the script: #!/bin/bash source /home/myscript/conf/config.conf echo "$username" and below is my config.conf: ...
0
votes
2answers
104 views

Shell script to work on files in some directory

I am a noob in Linux hence this might come as a silly question. I have a Windows system, so I downloaded cygwin to help me execute Linux/unix commands. I need to execute a shell script on a bunch of ...
0
votes
1answer
49 views

Echoing Total Page Number in Bash Script

I have the following script for batch pdf-ocr processing & it works fine #!/bin/sh # apt-get install exactimage tesseract-ocr ghostscript # bash tut: ...
0
votes
1answer
76 views

Combining multiple functions into a single bash script

Is there a way that I can combine the following commands (the last is a zsh function) into a single bash script? find /path/to/directory/*/* ! -name "*.js" -type f -delete find ...
0
votes
1answer
64 views

Converting windows date logic into Unix [closed]

I had coded the below logic in Windows batch scripting and I need to replicate the same in Unix. # Calculating Yesterday's Date for /F "tokens=1-4 delims=/- " %%a in ('date/T') do set DY=%%c for ...
0
votes
2answers
510 views

Convert json mapping object to managed csv row using bash script

I have json mapping under properties key as below in a file Customer.json, { "customer": { "properties": { "customerId": { "type": "string", ...
0
votes
1answer
117 views

Disable Touchpad automatically at startup

I'm running Mint 17 Mate on a new HP250 laptop. I can turn off the touchpad by typing the following from terminal: synclient TouchpadOff=1 Now I want to disable the touchpad automatically each time ...
0
votes
2answers
39 views

Output multiple strings out of multiple files

Hi my current code is: find /home/user/logfilesError/ -maxdepth 1 -type f -name "gBatch_*"\ -daystart -mtime -1 -exec grep -rl "ERROR" "{}" + | xargs -l basename if [ $? -eq 0 ]; then ...
0
votes
1answer
161 views

How to exit the script in ssh session?

My script contains a ssh command to login to remote server and execute a few commands, The command checks if a file exist and if not it should come out of the entire script. ssh $user@$hostname "if[ ...
0
votes
3answers
290 views

Checking if line in file exist

I have a bash script which asks a user for the number of CPU cores and saves it to variable named $cores. Now I want to add this variable to .bashrc, so I ask user how much CPU cores he has and then ...
0
votes
1answer
41 views

How can I search for a user account in various sudo related config files?

I'm a scripting newbie...and I would like to search multiple servers for user ss7459 in the following files /etc/sudoers, /etc/sudoers.d/itse, /etc/sudoers.d/dbas and /etc/group. NOTE: The numbers ...
0
votes
3answers
69 views

Looping the listing files in UNIX

I've given the command: ls -lrt and the listed files and directories are: drwxr-xr-x 4 root root 4096 Feb 2 2014 abc drwxr-xr-x 4 root root 4096 Feb 2 2014 cde drwxr-xr-x 4 root ...