Search Results

Search: Posts Made By: millsy5
2,339
Posted By RudiC
read man bash on Parameter Expansion / Substring...
read man bash on Parameter Expansion / Substring Expansion.
2,339
Posted By rbatte1
Would :-echo "$string" | tr -d "[a-z][A-Z]"... do...
Would :-echo "$string" | tr -d "[a-z][A-Z]"... do the trick or does this not handle enough possible characters?

Perhaps:-#!/bin/ksh
c1="${string%?}" # Get 1st character...
2,339
Posted By Ygor
Try something like...$ string1='3X' $ case...
Try something like...$ string1='3X'

$ case $string1 in [0-9][0-9]) : ;; [0-9]?) string1=${string1:0:1} ;; esac

$ echo $string1
3

$
1,840
Posted By verdepollo
I think you're confusing the concepts. In your...
I think you're confusing the concepts. In your original script you were trying to run a flat text file which happened to have a .c extension. Its contents cannot be interpreted by a shell nor by...
1,840
Posted By guruprasadpr
You cannot give the source file directly. Compile...
You cannot give the source file directly. Compile your C program and get an exe, and then execute the exe from the shell script.

Like:
Compile your C program:

$ cc -o myprog main.c
$ ls...
1,078
Posted By jim mcnamara
Yes, that will work the way you want. DON'T use...
Yes, that will work the way you want. DON'T use cpuset 0. It is a special set that represents all cpus. Which is the default without cpuset anyway.
1,343
Posted By Don Cragun
If you want the value converted to a number, you...
If you want the value converted to a number, you can try something like:
awk '
BEGIN { factor=1000 # change 1000 to 1024 if using ISO/IEC values
}
function f(v, ind) {
ind =...
1,343
Posted By joeyg
$ echo Mem: 100M Active, 2150K Cache, 500M Buf,...
$ echo Mem: 100M Active, 2150K Cache, 500M Buf, 10G Free | awk '{print substr($8,1,length($8)-1)}'
10
1,343
Posted By joeyg
$ echo Mem: 100M Active, 2150K Cache, 500M Buf,...
$ echo Mem: 100M Active, 2150K Cache, 500M Buf, 10G Free | awk '{print $8}'
10G

$ echo Mem: 100M Active, 2150K Cache, 500M Buf, 10G Free | awk '{print substr($8,length($8),1)}'
G


The first...
2,206
Posted By pamu
No this doesn't work like this. Here you normally...
No this doesn't work like this. Here you normally read a line by line from a file.

$ cat file
LINE1
LINE2
I_AM_SEPARATOR
LINE11
LINE22
I_AM_SEPARATOR

$ while read line; do echo $line;...
2,206
Posted By rdrtx1
#/bin/bash print Enter line: while read...
#/bin/bash

print Enter line:
while read myline
do
echo $myline
print Enter line:
done
6,203
Posted By jim mcnamara
The utility dos2unix converts files with...
The utility dos2unix converts files with DOS/Windows carriage control to UNIX carriage control. cygwin's unix2dos simply takes a file and converts it without redirecection needed.

dos2unix...
6,203
Posted By tukuyomi
\r is added by your text editor (Windows text...
\r is added by your text editor (Windows text editor?) at the end of each line (carriage return (http://en.wikipedia.org/wiki/Carriage_return#Typewriters))
You have to configure it to NOT write \r...
1,264
Posted By Scrutinizer
Sure: awk ' 1 #...
Sure:
awk '
1 # Perform the default action: {print $0} (print the line)
$1==3{ # if the first field equals 3
print RS s #...
1,264
Posted By Scrutinizer
Hi, try: awk '1; $1==3{print RS s}' s=" 3b ccc...
Hi, try:
awk '1; $1==3{print RS s}' s=" 3b ccc ccc ccc" infile
6,600
Posted By neutronscott
functionally the same sed but shorter without...
functionally the same sed but shorter without back-references sed 's/\.[^.]*$/_failed&/' :D
6,600
Posted By jawsnnn
Your basic global substitution syntax for sed is:...
Your basic global substitution syntax for sed is:

's/search_term/replace_term/g'

This sed command says that:

1. search for any character combination, i.e. \(.*\). Here .* represents any...
6,600
Posted By jawsnnn
My bad. This one inserts the "_failed" command...
My bad. This one inserts the "_failed" command before the extension.


#!/bin/ksh
if [ -e $1 ]; then
ofile=`echo $1 | sed 's/\(.*\)\.\(.*\)/\1_failed.\2/g'`
cp "$1" "${ofile}"
fi

...
6,600
Posted By rangarasan
bash
Hi,

Try this one,

#! /usr/bin/bash
base=$1
if [ -f ${base} ];
then
mv ${base} ${base/./_fails.}
else
echo "${base} file not found"
fi


Cheers,
Ranga:)
Showing results 1 to 19 of 19

 
All times are GMT -4. The time now is 01:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy