1,891 Topics

Member Avatar for
Member Avatar for duke.tim

How can an array be accessed from within another function? Here is an example of some code. editarray can not seem to access values of the array from outside of the writetofile function. Is there any way to change the scope of the array? #!/bin/sh writetofile() { templine=`cat /dev/stdin` export …

Member Avatar for Watael
0
245
Member Avatar for seacase

I am trying to modify my shell sort algorithm to use Hibbard's increments rather than n/2. I know that Hibbard's increments are 2k - 1, but I can't figure out how to incorporate that into my algorithm. Any suggestions to help me move forward with this? I feel like I …

Member Avatar for Mohamed_22
0
4K
Member Avatar for rje7

How to find the difference of two files and get a 3rd file with the newer information alone. for example: There are two files file1 and file2 **file1** apple mango pear **file2** apple mango pear cat and dog I need a file with **fileout** cat and dog how to achieve …

Member Avatar for rje7
0
156
Member Avatar for duke.tim

Why is it that no matter how long I put the sleep command or loop, cat is unable to read the file, even though the file already exsists? Is there any way of reliably waiting for the whois to finish, write to file and then read that the file exsists?? …

Member Avatar for duke.tim
0
241
Member Avatar for sudipta.mml

Hi all I want to login a machine remotely and doing some operation on the remote machine and then exit the remote machine by a unix shell script. I can login these two machines without passward. How can I do that? For example, my script is on machine1. that script …

Member Avatar for rubberman
0
301
Member Avatar for shamusk

I am new to the awk scripts. I am confused about the delimiter concept in the awk script. say delimiter is , or | or anything, then a new line is treated as a next line ? like e.g. 00|01|05|05|03|13|12|04|06|80| 03|01|01|00|52|10|12|11|05|12| So there are 10 fields in each row, and …

Member Avatar for Watael
0
159
Member Avatar for manuel.a.gonzalez.5494

I was wondering how could I solve this problem, I have a php project in which I have tables, but I didn't use `<thead>` and `<tbody>`, but now I am using DataTable jquery plugin, and it needs that the tables have them, so I need to modify all of my …

0
100
Member Avatar for leghorn

hi all only the weirdest thing happened with me just now. I was debugging a shell script and I found that a step that was supposed to execute later ws getting executed prior to another step for no reason. You know any ? i mean have a look at the …

Member Avatar for Watael
0
116
Member Avatar for techman41973

When using the Grep command to find a search string in a set of files, is there a way to dump the results to a text file? Also is there a switch for the Grep command that provides cleaner results for better readability, such as a line feed between each …

Member Avatar for JeoSaurus
0
306
Member Avatar for techman41973

occasionally I run a backup of my phpbb forum files from the Shell command line: zip -r forum_backup ~/public_html/forum/* I'd like to add date elements to the file name, so that the zip file created is automatically formed as forum_backup_05182013.zip or something similar Thanks

Member Avatar for JeoSaurus
0
258
Member Avatar for Meena Yegappan

Hi I am trying to run a python script which has this code snippet: process = subprocess.Popen('./start_ws.pl') process.wait() os.system('make') The perl script started changes environmental variables and enters into new subshell. After entering into new subshell, the commands below script os.system('make') goes unnoticed.They get executed only if i exit from …

Member Avatar for slate
0
493
Member Avatar for mossman mudas

i have an awk script and in the end section i create my table data with printf and i want to sort it so i used pipe then sort i am calling it like this awk -f awkscript file in bash i can get it to work the way i …

Member Avatar for mossman mudas
0
239
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
300
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
388
Member Avatar for chriswelborn

This is another useful script I came across. It prints a color-code chart in your terminal. It can help you find the color-code you are looking for, or view the current color-scheme you are using (people use it on reddit/r/unixporn to show off their system's theme, I use it to …

0
382
Member Avatar for chriswelborn

I didn't write this, the credits are in the code. It's a code-golf version, and I'm sorry about that. I am trying to 'decode' it but I don't have the skills, so the 'decoded' version doesn't have the right colors. This is an example of what you can do with …

0
1K
Member Avatar for leghorn

hi,a question .. why does my script work as sh script.sh and not as ./script.sh ?? also,i was trying to write a script that would filter out a pattern in a .txt file and display the count of the same. Say my pattern is king, and there are 4 "king"s …

Member Avatar for chriswelborn
0
148
Member Avatar for m_ishwar

Hello everyone. I am trying to compile this simple code using gcc under Cygwin terminal. //A function that just returns a value// int my_function() { return 0xbaba; } I saved the code as basic.c I issue the command $gcc basic.c in the Cygwin terminal And I get the error: gcc: …

Member Avatar for m_ishwar
0
608
Member Avatar for leghorn

hi New to shell scripting. While trying hands at it I came across the operators -z -o in the if block. Any relevant info would be appreciated **if [ -z "$xa_" -o "$va_" == "yes" ]** cheers guys

Member Avatar for leghorn
0
123
Member Avatar for Rahul47

vi is basically used independently .....but what if vi commands are used in shell script ? I am trying to accomplish functionality of mv command using a shell script. what I want is to yank whole text of one file1 and paste it in file2. this all should happen in …

Member Avatar for Watael
0
267
Member Avatar for lewashby

I'M wanting to write my own command/script for compiling my c++ files. I use g++ -g -Wall filename.cpp -o filename I'M trying to figure out how I can trip of the last four characters (.cpp) from a string. Any ideas?

Member Avatar for rojomoke
0
246
Member Avatar for toldav

Hi Any one can guide me to the right direction. I trying to run my scripts from anywhere, how about to do it: I did this but is not working. export PATH = $PATH:/scripts/pyhon But is not working Thank you

Member Avatar for L7Sqr
0
103
Member Avatar for yue.sun.35

Hi guys I try to run this shell in java but it never works. Process p = Runtime.getRuntime().exec(" cat *.java|sed '/import/d'|sed'/package/d'>>b.java "); when I change the cmd to something like "ls" or "open foo.java" the code will works. Any idea why?

Member Avatar for jwenting
0
94
Member Avatar for old_apache

i have 2 files, one file created on Windows and another was made on Ubuntu, i want to use this command: comm -12 file1 file2 how do i do that?

Member Avatar for old_apache
0
183
Member Avatar for old_apache
Member Avatar for coding101

trying to send email from nc nc smtp.gmail.com 587 HELO there 250 mx.google.com at your service STARTTLS 220 2.0.0 Ready to start TLS MAIL FROM:<junk@example.com> connection dies.. whats wrong with the protocol im using??

Member Avatar for JeoSaurus
0
108
Member Avatar for mossman mudas

i want to find the total space used for the files owned by me from my current directory. i have du -sh `find ./ -user $USER -type f` which gives 8.0K ./.a 8.0K ./t 4.0K ./cat/A 4.0K ./a using -s has no effect. using du -sh by itself includes the …

Member Avatar for mossman mudas
0
160
Member Avatar for saadi068

I am (student) just switched to linux working on NoC (noxim) simulator in ubuntu 12.04 c++ is supported assignment from university, I want to make a script that call my whole program multiple times (for loop= e.g 10) and want to take average value from the functions that were called …

Member Avatar for Watael
0
238
Member Avatar for Aamit

Hi, I have dates like 20130402 (y-m-d i.e 2ndApr13) Dates are 20130402, 20130404, 20130409, 20130412 if date is 20130402 out put is 20130408 , if date is 20130412 output is 201304015 dd="20130402" echo $dd This gives me current dates next monday , date -d "next monday" +%Y%m%d How to find …

Member Avatar for ahamed101
0
88
Member Avatar for sudipta.mml

my input file contais this text DOPC 1024 PW 30903 CL- 1 arg01 1 My output file should be DOPC 1024 PW 100 CL- 10 arg01 1 I have used this following command for the single substitution and it works well. read no_water read length sed s/"PW 30903"/"PW $no_water"/ arg01.top …

Member Avatar for sudipta.mml
0
181

The End.