Visit Our UNIX and Linux User Community

Search Results

Search: Posts Made By: apmcd47
21,763
Posted By apmcd47
Try appending this to your command: 2>...
Try appending this to your command:


2> >(grep -v 'No such file or directory' >&2)
It should remove the above message from the STDERR but allow other messages to be printed.


Works for bash...
4,224
Posted By apmcd47
That is close - try this while read product id...
That is close - try this
while read product id features
do
printf "${product}, %s\n" ${features%#*}
done < Check_FileYour example was using only two variables (f1, f3) to read the fields...
6,188
Posted By apmcd47
How about one of these two lines: [ -f...
How about one of these two lines:
[ -f /var/chef/cache/cookbooks/bootstrap_cookbooks_version_* ] && echo /var/chef/cache/cookbooks/bootstrap_cookbooks_version_* | sed 's/.*version_//'...
Forum: Programming 11-11-2019
15,122
Posted By apmcd47
realloc() is not guaranteed to reallocate in...
realloc() is not guaranteed to reallocate in situ, which is why you do
str = realloc(str, mem); rather than realloc(str, mem); The next_read variable should be reset with something like next_read =...
4,999
Posted By apmcd47
I was going to say I agree with RudiC, but...
I was going to say I agree with RudiC, but realise $LINE should be a subset of $1, not the other way round, so Rudi's solution probably won't get the results you want. So let's look at what is wrong...
10,332
Posted By apmcd47
GNU Zip will decompress .Z files, sogunzip -c...
GNU Zip will decompress .Z files, sogunzip -c somefile.tar.Z | tar xf -orzcat somefile.tar.Z | tar xf -should work without having to install the compress utility. It may even be possible to use GNU...
2,518
Posted By apmcd47
Please give an example of what your output should...
Please give an example of what your output should look like. Because the file as listed has 0s and 1s on all lines, and therefore grep as you propose to use it will delete all lines,


Andrew
1,606
Posted By apmcd47
Assuming GNU tail you can either list lines from...
Assuming GNU tail you can either list lines from the end (--lines=1234) or from the beginning (--lines=+1234) of the file. Thus listing the full file could be done withtail --lines=+1 myfile
In your...
32,825
Posted By apmcd47
Did you find any examples on the web? This is the...
Did you find any examples on the web? This is the article I was alluding to in my previous post (https://stackoverflow.com/a/38862221). Also the output of the df command you are using needs to be...
32,825
Posted By apmcd47
In light of Neo's comments, I'll only give you...
In light of Neo's comments, I'll only give you some pointers.

First, install jq. It is a tool for creating, validating and editing JSON files and can be used to extract data from a JSON file,...
5,039
Posted By apmcd47
My original sed solution had a typo. This version...
My original sed solution had a typo. This version works for both the samples you gave, with and without the quotes:
#!/bin/sh

printf "Parameter 1: %s\n" "$1"
MYARRAY=`echo "$1" | sed 's/^\[//;...
5,039
Posted By apmcd47
First, you need to quote your input: ./test.sh...
First, you need to quote your input:
./test.sh "[u/tmp/file.js, u/var/test.txt, u/tmp/llo.rft]"

Second, don't use the shell array construct - do this instead:
#!/bin/sh

FPATH="$1"

printf...
3,035
Posted By apmcd47
So basically you are asking, "is my login shell...
So basically you are asking, "is my login shell bash or ksh?" And if there is no bash on your system it will be ksh, because that is the default, else you will have changed it by the time your...
10,056
Posted By apmcd47
I'm guessing which is an external command in your...
I'm guessing which is an external command in your environment. As such it doesn't take into consideration builtin commands (which is why it is much better to use type on bash, ksh and dash). The...
10,072
Posted By apmcd47
Further to Neo's and Don Cragun's comments, the...
Further to Neo's and Don Cragun's comments, the variables used in your example are shell-specific variables and therefore do not need to be exported.

Andrew
Forum: Programming 04-02-2019
2,194
Posted By apmcd47
Try this: (Python 2.7.12 on Ubuntu 16.04 Xenial) ...
Try this: (Python 2.7.12 on Ubuntu 16.04 Xenial)

ss = system_info['Ad_List']
searchObj = "primary"
resList = [f for f in ss if searchObj in f]

resList will be a list of one object, or...
Forum: Ubuntu 04-02-2019
5,849
Posted By apmcd47
According to one of the comments in the link you...
According to one of the comments in the link you posted, the correct directory for this on a Debian, and therefore Ubuntu system, is /lib/systemd/system-sleep, not /usr/lib/systemd/system-sleep.
...
Forum: Ubuntu 03-27-2019
8,679
Posted By apmcd47
My own tuppence worth on this: As this is...
My own tuppence worth on this:

As this is in the Ubuntu sub-forum, ps has a -b (size in bytes) option;
If you want the size of a file in bytes, surely the most accessible (and therefore most...
367
Posted By apmcd47
select appears to take note of the LINES and...
select appears to take note of the LINES and COLUMNS variables set on terminal resize. Try adding COLUMNS=0into your code prior to the select statement.

Andrew
1,518
Posted By apmcd47
Basically $h{$_}++returns the value of $h{$_}...
Basically $h{$_}++returns the value of $h{$_} then increments it. If there is no value at $h{$_} perl will initialise it to zero.

So, for each value that $_ may be, the first evaluation is zero...
979
Posted By apmcd47
bash: for f in *.tex.txt do mv ${f}...
bash:
for f in *.tex.txt
do mv ${f} ${f/.tex/}
done

More Posix compliant (I believe):
for f in *.tex.txt
do mv ${f} ${f%.tex*}.txt
done

Andrew
1,530
Posted By apmcd47
DonCragun's code as posted would have worked. You...
DonCragun's code as posted would have worked. You modified a crucial part of that code, vis
for file in server.log-$filename_time2*
This expands the wildcard; the if statement then checks the first...
2,725
Posted By apmcd47
My point was that you can do string manipulation...
My point was that you can do string manipulation per element, or for all elements in an array of strings, thus:$ array=( john paul george ringo )
$ echo ${array[0]/h/}
jon
$ for btl in...
1,980
Posted By apmcd47
Except that your shell will evaluate $PATH before...
Except that your shell will evaluate $PATH before executing sudo. Instead you would need to do the somewhat iffy looking sudo bash -c "eval echo \$PATH"or better still get use sudo -i and check your...
2,084
Posted By apmcd47
Please use the code tags for code, like it tells...
Please use the code tags for code, like it tells you in the message window. You either need to use the in-place option to sed, or use an intermediate file, like this
sed 's/^.*$/"&"/' ${OUTFILE}...
Showing results 1 to 25 of 134

 

Featured Tech Videos

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