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

learn more… | top users | synonyms (2)

0
votes
2answers
235 views

Why do I get Illegal number: {1..3}

Why am I getting ./6_sum_square_difference.sh: 11: ./6_sum_square_difference.sh: Illegal number: {1..3} for #!/bin/sh summing () { the_total=0 num_in=$1 for one_num in {1..$num_in} do ...
0
votes
0answers
37 views

Mount /var at boot runlevel 2 - problems

I'm working with a system that (for various reasons) often gets corruption on the /var partition. To this end I'm hoping to run e2fsck on it during the regular boot. I've commented out the /var ...
0
votes
0answers
299 views

Establish communication between Arduino Mega & Linux Terminal in Ubuntu 14.10

I am failing regularly in establishing syncing between my arduino mega(/dev/ttyACM0) and the terminal. Even I thought of establishing output using GNU Screen utility. The terminal just hangs for ...
0
votes
2answers
40 views

executing commands in shell and turnoff the default displays of commands in console [duplicate]

This is my script cd /opt/product/vinoth -- some operations -- cd - While executing this command cd - the old path get displayed in the console. is there is any way to block this from displaying ...
0
votes
1answer
117 views

Shell string escape for command arguments [duplicate]

I'm trying to create "/tmp/pwet/foo bar" with this: DIR="/tmp/pwet/foo bar" ARGS="-p ${DIR}" mkdir $ARGS For integration reasons, I have to keep the ARGS building in 2 steps: ARG = some_options + ...
0
votes
0answers
26 views

What does sort -n do with non numeric values? [duplicate]

I'm translating an old korne shell script that uses sort. The exact command is: sort -k 1.2,1.9n -k 1.10 -k 1.18,1.19 $LOAD_FILE > $SORTED_FILE The input file has some lines where the values in ...
0
votes
1answer
665 views

Init script to run a script as specific user

/apps/data/service/bin/startup.sh This is the script i want to be executed during RHEL booting. I want it to be run in runlevel 3 only. And i want this script to be started as specific user, ...
0
votes
1answer
363 views

Capture Error of LS to file [duplicate]

#!/bin/sh if [ $(ls sample01.log | wc -l) = 1 ] then echo "File Found" > lsOutput.log else echo "File Not Found" > lsOutput.log fi But if sample01.log is not already existing my code already ...
0
votes
1answer
336 views

need to display hard error , transport error & soft errors above 2

iostat -En | nawk '/Hard Errors/ {line=$0;gsub(/.*Hard Errors:/,""); \ if($1>2) printf("%s\n",line); }' The output of this is c0t1d0 Soft Errors: 0 ...
0
votes
2answers
347 views

read file record by record and do transformation to the subsequent record based on above record and write into another file

Data file is fixed length file, and I want to read the file record by record and do transformations to the subsequent records based on the prior records (and write the results into another file). ...
0
votes
2answers
206 views

file command + how to view all results from file command

I use the file command in order to verify if file (PATH) is text/ascii file or encrypted file Because file command have allot of results ( small example in example 1 ) I want to get the all ...
0
votes
2answers
806 views

Bash script error trying to find directory of script itself: unexpected end of file

Borrowing graciously from this StackOverflow answer, I want to find the directory a script is running in so I can load relative paths for it on login: The script is pretty small right now: ...
-1
votes
1answer
1k views

Commands not found in shell script

I need to execute scp command without using expect command in script. How to use scp with password? I have tried with following code. HOST=lnx1 USERNAME=user PASSWORD=pwd PATH=/sample/data/ FILE=$1 ...
-1
votes
3answers
420 views

How can I select columns based on a control file with invalid column numbers?

I have to generate the file dynamically from the source file based on the below control file. control_file.txt 1,3,5,-1,8,-1,4 The control file contains the position of columns which I require ...
-2
votes
1answer
123 views

How to find files with the smallest size in a directory

I need to find all files of the smallest size in a directory. My code so far: #!/bin/bash dir="$1" printf "minimum file size: %s\n" du $dir -hab | sort -n -r |tail This code ...
-4
votes
2answers
906 views

“bash: [: : integer expression expected” [closed]

I want this function to return one random word if there aren't any command-line arguments. I am modifying linuxconfig.org's random-word generator to run even when #$ -ne 1. function random-word { ...