Visit Our UNIX and Linux User Community

Search Results

Search: Posts Made By: learnbash
1,935
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...
1,935
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...
2,309
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.
798
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"
25,888
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...
7,529
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,403
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,403
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,403
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
890
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 ]
890
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
890
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
890
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,421
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,421
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 }
...
2,017
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}...
922
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
...
922
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...
2,456
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
2,456
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
2,456
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
...
759
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,075
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
813
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...
13,018
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

 

Featured Tech Videos

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