Search Results

Search: Posts Made By: learnbash
2,769
Posted By Corona688
From your output: 00027f80 77 00 77 00 77...
From your output:

00027f80 77 00 77 00 77 00 2e 00 71 00 61 00 74 00 61 00 |w.w.w...r.a.t.p.|

Normal text: hexdump -C /etc/gentoo-release
00000000 47 65 6e 74 6f 6f 20 42 61 73 65 20 53...
2,769
Posted By Corona688
Your file is not ASCII at all but 16-bit Unicode,...
Your file is not ASCII at all but 16-bit Unicode, and as I suspected (but you refused to say) must have come from a Windows system. I guess your version of vi either detected and converted it, or...
3,150
Posted By Scott
The problem has been resolved. Please let us know...
The problem has been resolved. Please let us know if you have any further problems. Thanks.
997
Posted By Scott
Exporting the function won't help, since you're...
Exporting the function won't help, since you're calling it from its parents shell.

You will need to source the file, and quote the commands:


# su - test -c ". /home/test/.bash1; hello"
32,641
Posted By disedorgue
Ok, I found error, it's date format: $ date...
Ok, I found error, it's date format:
$ date --date='30 minutes ago' '+%b %d %H:%M'
Oct 01 20:20
In log, not 01 but 1 (with space):
as like:
$ date --date='30 minutes ago' '+%b %_d %H:%M'
Oct 1...
9,549
Posted By disedorgue
Hi, You can do it (in concept): input file...
Hi,
You can do it (in concept):
input file example:
$ cat file1.log
Sep 15 01:41:33 servername
Sep 15 01:46:05 servername
Sep 15 02:46:05 servername
Sep 15 02:41:33 servername
Sep 15 02:46:05...
1,743
Posted By MadeInGermany
pgrep '^httpd$' is the same as pgrep -x httpd...
pgrep '^httpd$'
is the same as
pgrep -x httpd
Instead of -n (newest) I would take -o (oldest), or pick the one that is spawned by init (PID 1)
pgrep -P 1 -x httpd
NB in Solaris zones the latter...
1,743
Posted By ahamed101
Yes, that should do. And btw you can check the...
Yes, that should do.
And btw you can check the output of pgrep directly rather than checking the exit status.

--ahamed
1,743
Posted By ahamed101
Why not use pgrep? pgrep -nf...
Why not use pgrep?


pgrep -nf /usr/sbin/httpd


This will return you the pid of the latest httpd process.

--ahamed
1,962
Posted By Scrutinizer
Sure, no problem: awk ' ...
Sure, no problem:
awk '
NR==1 # If it is the first line in the file it is the header, perform the default action, i.e. print the line { print $0 }
...
1,962
Posted By Scrutinizer
OK, try something like: awk 'NR==1;...
OK, try something like:
awk 'NR==1; NR>1{A[$2]+=$3; C[$2]++} END{for (i in A) print i,A[i]/C[i]}' OFMT='%.2f' file
1,131
Posted By radoulov
Or: ps -fu myuserid | grep [j]ava > /dev/null...
Or:
ps -fu myuserid | grep [j]ava > /dev/null &&
echo 'process is running' ||
echo 'process not running'if ps -fu myuserid | grep [j]ava > /dev/null; then
echo 'process is running'
else...
1,131
Posted By Don Cragun
if [ $(ps -fu myuserid | grep -c [j]ava) -gt 0 ] ...
if [ $(ps -fu myuserid | grep -c [j]ava) -gt 0 ]
then echo 'process is running'
else echo 'process not running'
fi
1,131
Posted By krishmaths
x=$(ps -fu myuserid | grep [j]ava | awk '{print...
x=$(ps -fu myuserid | grep [j]ava | awk '{print $2}')
if [ ! -z $x ]
then
echo process is running
else
echo process not running
fi
1,131
Posted By pamu
If should have space between brackets... can...
If should have space between brackets...
can reduce one grep
and avoid use of back tick's

try

x=$(ps -fu myuserid| grep -v grep | awk '/java/{print $2}')

if [ $x -eq 0 ]
3,544
Posted By MadeInGermany
Should be $13=="" not ! $13; the latter treats a...
Should be $13=="" not ! $13; the latter treats a 0 like a "".
If you want to include the error in the output file, you can do that in awk
awk -F, '
($13=="") {print "Error in file"; exit 1}...
1,161
Posted By Don Cragun
Here is another way to do it assuming that you...
Here is another way to do it assuming that you always have 4 input lines / output line and that the input lines are always in the same relative order. It uses slightly different headings than you...
1,161
Posted By Chubler_XL
How about this: awk ' { col=$0 ...
How about this:

awk '
{
col=$0
line=$0
gsub(/ *= .*/, "", col)
gsub(/^[^=]*= /, "", line)
if (!(col in COLS)) {
head=head OFS col
TITLE[++cols]=col
...
3,154
Posted By pravin27
How about this for i in `ls [0-9]-*.txt` do ...
How about this
for i in `ls [0-9]-*.txt`
do
mv "$i" "0${i}"
done
3,154
Posted By ahamed101
for file in *.txt do [[ ${file%%-*} -ge 10...
for file in *.txt
do
[[ ${file%%-*} -ge 10 ]] && continue
echo "mv $file 0$file"
done


--ahamed
3,154
Posted By Yoda
Like I said before, the code was based on some...
Like I said before, the code was based on some assumptions.

I assumed your file names are abcd1.txt, abcd2.txt ... abcd10.txt

Here is the modified code that might work for you:
#!/bin/bash
...
1,091
Posted By Joseph_TKLee
awk '{ for (i=1; i <=NF; i++) if(substr($i,1,1)...
awk '{ for (i=1; i <=NF; i++) if(substr($i,1,1) == "V") print $i }' file_name


Cheers,
1,753
Posted By Franklin52
Why don't you try it out for yourself with...
Why don't you try it out for yourself with something like:
for BLOCK in /sys/block/myblock[a-z]*
do
echo "$BLOCK"
done
1,285
Posted By Corona688
The 'for' loop can do what you want. for...
The 'for' loop can do what you want.

for BLOCK in /sys/block/emcpow*
do
echo "100000" > "$BLOCK"/queue/nr_requests
echo "noop" > "$BLOCK"/queue/scheduler
done

#3 can be...
20,127
Posted By jim mcnamara
find /abcd -mtime -1 -type f -exec cp {} /xyz/ \;
find /abcd -mtime -1 -type f -exec cp {} /xyz/ \;
Showing results 1 to 25 of 31

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