Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - leogtz

#1131
@moikano→@

Código (dos) [Seleccionar]
if %dat%==%%~a (echo Coincide %%a && pause > nul ) else (echo No coincide %%a && pause > nul)

Poner varias sentencias en una línea es un mal habito de programación.
#1132
Scripting / Re: necesito ayuda [python]
22 Diciembre 2010, 18:42 PM
Si estás en Windows ejecutalo desde la línea de comandos (cmd.exe) para ver si hay algún fallo.
#1133
Las funciones retornan un valor, puede ser el resultado de una operación.

Ejemplo, función área, retorna el área de un rectángulo:

int area(int base, int altura)
{
     return base * altura;
}


El tipo de dato devuelto por la función dependerá de lo que quieras hacer, en este caso se trató con enteros, pero pudo hacerse con short, double, float, long, etc.

El return es necesario para que al llamar a la función esta nos devuelva algo.

ejemplo:


#include <stdio.h>
int area(int base, int altura)
{
return base * altura;
}
int main(void)
{
printf("El area del rectangulo de base 2 y altura 3 es : %d\n", area(2, 3));
return 0;
}


int main() es una función, de tipo entero, por lo tanto devuelve un valor, es por eso que se utiliza la sentencia return. El return devuelve un valor al sistema operativo, este de acuerdo a cómo se dió la ejecución del programa, es decir, si el programa se ejecutó bien se retorna un 0, si se ejecutó mal se retorna por lo general algo distinto a 0.

#1134
Scripting / Re: Recursividad en bash
21 Diciembre 2010, 22:10 PM
Pon el código completo, por favor, para que otros vean cómo quedó.

Respecto a sed.

Código (bash) [Seleccionar]
echo -e "$string" | sed "s/\.\///g"
#1136
Scripting / Re: Recursividad en bash
21 Diciembre 2010, 07:37 AM
La sintaxis sería:

find OPCIONES -exec cp -f {} DESTINO \;

Te dejo un ejemplo:


Código (bash) [Seleccionar]
leo@leo-desktop:~/Escritorio$ find . -type f -iname "vocabulario.txt" -exec cp -vf {} /home/leo/ \;
«./vocabulario.txt» -> «/home/leo/vocabulario.txt»
leo@leo-desktop:~/Escritorio$


{} Hace referencia al archivo en cuestión.
/home/leo/ sería el destino.

\; Necesario para terminar el find.
#1137
tokens=* obtienes todos los trozos de cadena, tokens no se refiere a lineas, sino a tokens.

('ver') comando a ejecutar y obtener su salida.

set var=%%a

Se obtiene la salida del comando ver.

Fuera del ciclo haces la extracción de caracteres.
#1138
Scripting / Re: Recursividad en bash
20 Diciembre 2010, 18:31 PM
A mi se me ocurre usar find con sus test's, find trabaja de manera rápida.

Código (bash) [Seleccionar]
TESTS
      Some tests, for example -newerXY and -samefile, allow comparison between the file currently being examined and some reference file specified on  the  command  line.
      When  these  tests are used, the interpretation of the reference file is determined by the options -H, -L and -P and any previous -follow, but the reference file is
      only examined once, at the time the command line is parsed.  If the reference file cannot be examined (for example, the stat(2) system call fails for it), an  error
      message is issued, and find exits with a nonzero status.

      Numeric arguments can be specified as

      +n     for greater than n,

      -n     for less than n,

      n      for exactly n.

      -amin n
             File was last accessed n minutes ago.

      -anewer file
             File  was last accessed more recently than file was modified.  If file is a symbolic link and the -H option or the -L option is in effect, the access time of
             the file it points to is always used.

      -atime n
             File was last accessed n*24 hours ago.  When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so  to
             match -atime +1, a file has to have been accessed at least two days ago.

      -cmin n
             File's status was last changed n minutes ago.

      -cnewer file
             File's status was last changed more recently than file was modified.  If file is a symbolic link and the -H option or the -L option is in effect, the status-
             change time of the file it points to is always used.

      -ctime n
             File's status was last changed n*24 hours ago.  See the comments for -atime to understand how rounding affects  the  interpretation  of  file  status  change
             times.

      -empty File is empty and is either a regular file or a directory.


find combinado con -exec, investigalo bien, seguro que te ayuda.

http://content.hccfl.edu/pollock/unix/findcmd.htm
#1139
Como ya te indicaron:

Código (dos) [Seleccionar]
for /f "tokens=*" %%a in ('ver') do (
    set "v=%%a"
)


#1140
Scripting / Re: Recursividad en bash
20 Diciembre 2010, 07:21 AM
¿qué es lo que quieres hacer con ese script?

Lo digo para ver si hallamos otra alternativa.