84 Topics

Member Avatar for
Member Avatar for Luigi_4

I have a script that uses grep to extract data from a file. It works but I am now trying to modify the script for pipeline use. If I use the commands: `cat file | myScript.sh` there is an error because the data reaches myScript.sh as it was collected by …

Member Avatar for JasonHippy
0
429
Member Avatar for AndrisP

How i can `sed` save pattern matches to variables and do something with it? eg $ echo "string_4.3.2" | sed 's/^string_\([0-9]\)\.\([0-9]\)\.\([0-9]\)$/\1 \2 \3/' output "4 3 2" but I want to pass variables to function eg do_something() { echo $1 echo $2 echo $3 # ..... # ..... } string="string_4.3.2" …

Member Avatar for AndrisP
0
840
Member Avatar for pirulo64

Hello, I'm trying to get this piece of script working, but I'm having an issue on my script. The if [ $DEV_ORA -eq 0 ] is not get run when I run my script. I do not know what I'm doing wrong here. Basically I trying to run the second …

Member Avatar for pirulo64
0
300
Member Avatar for houndhen

I am using a bash script to toggle the touchpad on my laptop. I didn't write the script and know almost nothing about bash scripts. I have the script run when the laptop boots because I never want to use the touchpad and want it disabled. The script does the …

Member Avatar for Gribouillis
0
628
Member Avatar for ananddvk

For loop is not working with expect in pgp encyption script. ========= -bash-4.1$ more TestScriptPGP.sh #!/bin/bash #!/usr/bin/expect -f for i in `ls *.txt` do spawn /opt/PGP/pgp -e +force $i "<[email protected]>" expect "Are you sure you want to use" send "y\n" expect "$" done; -bash-4.1$ ./TestScriptPGP.sh ./TestScriptPGP.sh: line 5: spawn: command …

Member Avatar for Roger_4
0
668
Member Avatar for script_noob

input.txt is a file that contains filenames that have been piped into it from an external program. for example... input.txt has the following in it filename1.txt filename2.txt filename3.txt I would like to perform an 'rm' command on the filenames contained in input.txt So instead of potential hours of work deleting …

Member Avatar for r 7vtgj
0
9K
Member Avatar for it@61@sec

I have a C++ program with a main routine which reads arguments from command line: int main(int argc, const char *argv[]) In my system I have defined some aliases in my bash environment which abbreviates directory names. Example: alias dst='home/username/Documents/test' alias src='home/username/Download/test' My program is called "dircopy" and I want …

Member Avatar for it@61@sec
0
331
Member Avatar for rohan1111

#ss4 #Usage: ss4 <filename> chmod 744 $1 $1 Hi this is my script , after executing it i am getting error as "./ss4: line 6: ss1: command not found" HELP me.

Member Avatar for rohan1111
0
213
Member Avatar for Zizou_1

Month CBS GFS HR HR Payroll INCV cbs1 gfs1 hr1 hr2 hrm incv1 Baseline <=97 <=125 >=11 >=19 <=25 10 (6mths) 2013-07 97 89 14 28 30 4 2013-08 58 103 18 6 24 18 2013-09 54 110 11 14 25 17 2013-10 108 129 17 8 23 18 2013-11 …

0
286
Member Avatar for lewashby

How can I write bash script to force pre-written sql quaries and inserts into my sqlite3 DB? I am currently having to run my page in a browser and then the sqlite4 DB gets edited by php commands then I have to go back into sqlite3 and manually set everything …

Member Avatar for rubberman
0
274
Member Avatar for theashman88

I'm having some error in my code but I can't understand what the problem is. #!/bin/bash ARG_COUNT=$# EXP_ARGS=2 if [ $ARG_COUNT -eq $EXP_ARGS ]; then echo "The correct number of parameters was passed: " $EXP_ARGS"." echo "My name is: "$1 $2"." else echo "Incorrect number of command line arguments. We …

Member Avatar for theashman88
0
284
Member Avatar for lewashby

In the code below how do I get sed's find and replace value to cary over into the output that gets redirected to the .txt file at the end? Everything else gets replaced but everything in the if statement gets left behind. # example: ./configure input-file, SSID, IP, device-name, gateway, …

Member Avatar for praom2104
0
270
Member Avatar for Logan_2

help with the script down here. I am so confuse as to why it is not working. I've change this thing back and forth and getting no where. It is driving me crazy. The error message keep saying script2: line 10: syntax error near unexpected token `done' script2: line 10: …

Member Avatar for L7Sqr
0
2K
Member Avatar for lewashby

In the following script I need to know if the configuration files is for a 2.4 or a 5.2 radio. This info is found in the filename so I'm trying to use grep -l *2.4* to find out if it's a 2.4 config file or not. If it's not the …

Member Avatar for lewashby
0
422
Member Avatar for lewashby

I How can I get the output from grep into a variable? In the following program I've tried the SSID line two ways but I am not getting what I want. `SSID=$(grep) ${FILE} -o empty-ssid` Gives me this garrett@bedroom ~/Desktop/folder/project $ ./testScript.sh ../OLD-172.28.50.30-system.cfg Usage: grep [OPTION]... PATTERN [FILE]... Try 'grep …

Member Avatar for lewashby
0
703
Member Avatar for rectifryer

I have a snippet of code that works when used in its own .sh file: #! /bin/bash LastFileUpdate=`find $dir -name $SearchString -type f -printf '%T@ %p\n' | sort -n | tail -n 1| awk '{print $1}'` echo $LastFileUpdate This code works on its own, but when I insert it into …

Member Avatar for rectifryer
0
267
Member Avatar for lewashby

In the following script I'm trying to have an automated task to move all the screen shots I have taken with the "Prt Scr" button from ~/Pictures to ~/Pictures/ScreenShots Any ideas why it's not working. I did it at first with the mv command but was told by my instructor …

Member Avatar for lewashby
0
745
Member Avatar for lewashby

In the following script I'm trying to have an automated task to move all the screen shots I have taken with the "Prt Scr" button from ~/Pictures to ~/Pictures/ScreenShots Any ideas why it's not working. I did it at first with the mv command but was told by my instructor …

Member Avatar for mike_2000_17
0
165
Member Avatar for dancks

I am trying to make something similar to a symbolic link type setup for a folder. I have a folder on my desktop, place_on_server, and several folders that match up to folders on my linux server so place_on_server/tutorials would match up to /var/www/media/tutorials or place_on_server translates to /var/www/media Basically I …

Member Avatar for dancks
0
1K
Member Avatar for chriswelborn

I'm no pro when it comes to BASH, but I have been known to shell-script my way out of a problem here and there. One of the useful things you can do is a for-loop, whether it be used on file names, script arguments, or just a string of words. …

Member Avatar for chriswelborn
0
312
Member Avatar for chriswelborn

I'm no pro when it comes to BASH, but I have been known to shell-script my way out of a problem here and there. One of the useful things you can do is a for-loop, whether it be used on file names, script arguments, or just a string of words. …

Member Avatar for chriswelborn
0
422
Member Avatar for gurkirts

echo enter the any no. read n fact=1 for(i=1;i<=b;i ) do fact=fact*i done echo factorial is fact

Member Avatar for <M/>
0
284
Member Avatar for supas14

I'm trying to write code to simulate the shortest job next or shortest process next using bash and I'm having some trouble grasping the logic behind it. I read from a file that has proces name, arrival time, and burst time. So let say A | 1 | 5 B …

0
84
Member Avatar for gtam

Hello I'm writing a script to get content of web pages on different machines and compare them using their md5 hash hear is my code #!/bin/bash # Cluster 1 CLUSTER1_SERVERS="srv01:7051 srv02:7052 srv03:7053 srv04:7054" CLUSTER1_APPLIS="test/version.html test2/version.html test3/version.jsp test4/version.html test5/version.jsp" # Cluster 2 CLUSTER2_SERVERS="srv01:7055 srv02:7056 srv03:7057 srv04:7058" CLUSTER2_APPLIS="test/version.html test2/version.html test3/version.jsp test4/version.html" # …

Member Avatar for Watael
0
238
Member Avatar for replic

Hello everyone, i am fairly new to shell scripting so please bear with me. The following script is supposed to read words from a file and depending on the word print different things. However it always prints the default value. It also refuses to work completely if the first line …

Member Avatar for replic
0
345
Member Avatar for dihmen

how can i create a script to backup sub-directories using Tar & Gzip, define threshold, and SSH file to remote host

Member Avatar for ashiiiish
0
163
Member Avatar for dihmen
Member Avatar for dihmen
Member Avatar for dancks

I made a website in php4 that I want to swtich over for my database, I'm a linux newb, I just thought I would write a simple sed script to change the username and password used in mysql_connect: #!/bin/bash for f in * do sed 's/mysql_connect('localhost','user1','pass1')/mysql_connect('localhost','user2','pass2')/' <$f >$f done exit …

Member Avatar for dancks
0
186
Member Avatar for ashleytauari

#!/bin/bash LOGFILE=/var/log/backup.log backup_source="/home" backup_dest="/home/sean" date=`date '+%d-%B-%Y'` hostname=$(hostname -s) filename="$hostname-$date.tgz" echo "Backing Up your Linux System" tar cvpzf $backup_dest/$filename $backup_source LOGFILE="log-$date.log" log(){ message="$@" echo $message echo $message >>$LOGFILE } log "$LOGFILE" log | tee install.log echo "Backup finished" echo "$LOGFILE" hie I'm trying append teh files i have backed up into …

Member Avatar for CGSMCMLXXV
0
208
Member Avatar for lewashby

I'M trying to test a function that would be able to determine if it was or was not leap year. I believe my problem lies in the if statement but due to my lack of knowledge concerning shell I don't know what else to do here. #! /bin/bash read -p …

Member Avatar for Watael
0
196
Member Avatar for stupendousomega

I understand that variables are global unless otherwise stated local, but for some reason, (and it's probably my own stupidity) it's not working. I have searched around to no avail. #!/bin/bash function a { echo $1 } echo $1 a Say you pass the word car to it. It should …

Member Avatar for Watael
0
145
Member Avatar for lewashby

bash: bld: line 11: syntax error: unexpected end of file I'M gettting the above when I source the attached script file. Can someone please let me know what I've got wrong here? Thanks The script file was build from the commands here > http://www.linuxfromscratch.org/lfs/view/stable/chapter06/gmp.html

Member Avatar for Member #838794
0
150
Member Avatar for lewashby

lfs@debianlfs:/mnt/lfs/sources/Chapter-5/5.10._GCC-4.6.2_-_Pass_2/gcc-4.6.2$ . bld bash: bld: line 44: syntax error near unexpected token `)' bash: bld: line 44: ` --with-mpfr-lib=$(pwd)/mpfr/src/.libs 2>&1 | tee gcc-configure.log && exit $PIPESTATUS ) &&' I'M getting the above error when I run my script. I've attached the scripts and I would really appreciate it if someone …

Member Avatar for sepp2k
0
90
Member Avatar for Member #825775

I have some scripts on my server which I use to maintain it. Some deal with NginX, others with backups, some with user creations, etc. I've written all of these with bash, and it has been working perfectly. But these scripts have become really big and it become really hard …

Member Avatar for CimmerianX
0
161
Member Avatar for Sanchixx

does anyone know how to add one to an integer with bash? I tried ++$i (name of the integer)

Member Avatar for L7Sqr
0
144
Member Avatar for dwlamb

I am new to bash scripting. Is it possible to get a value returned on a nested variable? At the command line, the following code will generate desired ouput: while read line; do echo -e "${line:21}"; done < Albums-linux.txt It takes a list of directories for albums and returns a …

Member Avatar for JeoSaurus
0
475
Member Avatar for griffman99h

Hope my first post is relevant enough. I'm a newbie coder and this is as much a learning exercise as it is a favor for my girlfriend. She has test results from a device that outputs data to .csv in multiple (100+) files. the important data is the separate file …

Member Avatar for L7Sqr
0
323
Member Avatar for rusman

I have written a very simple bash script that runs on Solaris10. It runs a command and then sends me the output via mailx. I can run it at the command line (sudoed as root) and it runs perfectly fine. I then set it up to run from cron. I …

Member Avatar for rusman
0
139
Member Avatar for Felipevd

Hey guys, I was doing some basic bash shell script, as I am new to this, and I can't seem to pass over this error. Here is the code: [CODE] #!/bin/bash echo "Please, type in the day of the week." read Day if (($Day="Monday"));then Monday=date +%d Tuesday=$(($Lunes+1)) Wednesday=$(($Martes+1)) Thursday=$(($Miercoles+1)) Friday=$(($Jueves+1)) …

Member Avatar for JeoSaurus
0
158
Member Avatar for java_programmer

I was trying to run a shell script and run it through Cygwin terminal in XP environment. The script I have written is as follows - [CODE]#!/bin/bash read -p "Enter Your name - " fname if test "$fname" == "abcd" then echo "Thank you abcd" fi[/CODE] When I am trying …

Member Avatar for java_programmer
0
705
Member Avatar for yawjava

How will I run the below code in the background while I sign off or forget about it till is done? [CODE]for file in *; do `ffmpeg -i $file -ab 192k -ar 44100 -acodec libmp3lame /home/afrispot/audios /converted/$file.mp3`; done[/CODE]

Member Avatar for rubberman
0
101
Member Avatar for SakuraPink

Hi there, Here is the problem: I have a Text file with several hundreds of lines and I want to store line 100 to 200 in another text file. I wrote the following piece of code but result is all of the lines not just the ones that I need. …

Member Avatar for SakuraPink
0
251
Member Avatar for anjoz

I need to make a recycle bin code using bash my problem is that i dont know how to get the previous path of the files that ive deleted so when i restore it it will go to the directory that it was deleted from ive tried putting the paths …

Member Avatar for JeoSaurus
0
377
Member Avatar for winecoding

I am trying to understand one test script, which includes [CODE]if [ ! -f mahout-work/reuters21578.tar.gz ]; then echo "Downloading Reuters-21578" curl http://kdd.ics.uci.edu/databases/reuters21578/reuters21578.tar.gz \ -o mahout-work/reuters21578.tar.gz fi[/CODE] What does the condition of [CODE]! -f mahout-work/reuters21578.tar.gz [/CODE]mean? And what does [CODE]curl http://kdd.ics.uci.edu/databases/reuters21578/reuters21578.tar.gz \ -o mahout-work/reuters21578.tar.gz [/CODE]stand for? Thanks.

Member Avatar for alaa sam
0
267
Member Avatar for Freude

Hello everyone, I am trying to use gnuplot for visualization of data stored in a file which is dynamically changed during computations. My aim is visualization of data from this file every several seconds during computations. How can I refresh gnuplot output produced in the bash script (usually i call …

Member Avatar for Freude
0
129
Member Avatar for tikoti

Hi all, I am really new in bash scripting and I can't even make simple tasks What I am trying to do is executing a command (ls -l for this example), over a double leap ssh. [CODE] #!/bin/bash ssh -T myuser@entrypoint ssh -T myuser@targetpc<<EOI ls -ltr . exit EOI [/CODE] …

Member Avatar for thekashyap
0
261
Member Avatar for trume

Hi! I'm new in shell scripting, so please help me with my problem. How can I do a bash script's [B]for loop[/B] to find the smallest number? If I have an example: 1 4 6 23 5 7 100 2 Answer: 1 It needs to be a for loop. Any …

Member Avatar for Potion
0
200
Member Avatar for dspjm
Member Avatar for nonshatter
0
233
Member Avatar for dspjm

As the title, type M-C-y, can use it, but what if i want to use the argument to recall the nth argument in the previous command...Thanks for answering...

Member Avatar for dspjm
0
524

The End.